选择框架时要考虑的6件事

You’ve decided that it makes sense to use a framework when writing your next new application, and chances are that if you’re already familiar with a specific framework, then you’ll probably be leaning towards using that one when you start. But are you sure it’s really the most appropriate for the task at hand?

您已经决定在编写下一个新应用程序时使用框架是有意义的,并且很有可能,如果您已经熟悉了特定的框架,那么开始时可能会倾向于使用该框架。 但是您确定它真的最适合手头的任务吗?

In the name of due-diligence, here are some of questions that you should ask yourself before settling on a particular framework to make sure you’re not programming “against the grain” and also to make sure it will be able to meet your needs now and in the long-term.

以尽职调查的名义,在确定特定框架之前,您应该问自己一些问题,以确保您不会“违背规则”进行编程,并确保它能够满足您的需求现在和长期。

我从框架中需要什么? (What do I need from the framework?)

Familiarity is important, but functionality is more so. Therefore, consider what functionality you really need from the framework. It doesn’t make sense to use a full-stack framework if you only need routing capabilities, for example. Once you’ve identified what your situation requires, you can begin to intelligently compare the offerings of the myriad of available frameworks, whittling down your choices making it easier to choose a final candidate.

熟悉很重要,但功能更重要。 因此,请考虑您从框架中真正需要的功能。 例如,如果仅需要路由功能,则使用全栈框架没有任何意义。 一旦确定了您的情况所需,就可以开始智能地比较各种可用框架的产品,减少选择范围,从而更轻松地选择最终候选人。

我希望该框架有助于管理一致性吗? (Do I expect the framework to help manage consistency?)

It can be difficult to maintain proper communication in a large team of developers, especially if the team is distributed. Individuals will have their own preferences when it comes to formatting code, naming objects, etc. and may re-implement code that is already available in elsewhere in the codebase. Frameworks can help in this regard, but be mindful of depending on it too much to maintain consistency. A framework is not a replacement for coding standards, code reviews, and other internal control policies.

在大型开发人员团队中保持适当的沟通可能很困难,尤其是在团队分散的情况下。 在格式化代码,命名对象等方面,个人将有自己的偏好,并且可能会重新实现代码库其他地方已经可用的代码。 框架可以在这方面有所帮助,但请注意不要过多依赖框架以保持一致性。 框架不能替代编码标准,代码审查和其他内部控制策略。

有好的文档吗? (Is good documentation available?)

I’m sure we’ve all experienced how difficult it is to understand code we’ve written, set aside for six months, and then come back to. Even though we wrote it, it seems as if we’re reading it for the first time. With a framework, you’re always reading and working with someone else’s code. Choosing a framework with a history of providing good documentation and training will make understanding the code and using the framework to its fullest potential much easier.

我敢肯定,我们所有人都已经经历了理解我们编写的代码,搁置六个月然后再返回的难度。 即使我们写了它,似乎我们还是第一次读它。 使用框架,您将始终在阅读和使用其他人的代码。 选择具有提供良好文档和培训历史的框架将使理解代码和最大程度地利用框架变得容易。

框架是否正在积极开发中,并且拥有活跃的用户群? (Is the framework actively developed, and does it have an active user base?)

It’s time consuming to write code that isn’t tightly-coupled with the underlying framework, thus it’s all too common for a framework to become an integral part of an application. So if the framework you rely on ends up fizzling out, you’ll be faced with two choices: stay with the framework and take on its maintenance yourself, or re-write your code to use a new framework. Neither are very enticing propositions! It’s imperative to make sure you don’t get stuck with a ticking time bomb, so take the time to research the history and community of a framework while you’re still in the planning stages so you can avoid this pit fall.

编写与底层框架没有紧密耦合的代码非常耗时,因此,框架成为应用程序不可或缺的一部分太普遍了。 因此,如果您所依赖的框架最终失败了,您将面临两种选择:呆在框架上并自己进行维护,或者重新编写代码以使用新的框架。 两者都不是很诱人的主张! 必须确保您不会被定时炸弹所困扰,因此,在尚处于计划阶段时,花点时间研究框架的历史和社区,以便避免陷入困境。

框架可以在我的生产环境中工作吗? (Does the framework work in what I run in production?)

PHP programmers generally have the luxury of writing applications that will run in a known environment, as opposed to JavaScript programmers who must deal with different combinations of browsers and platforms, but still the PHP environment can change. The operating system can be upgraded; the PHP version number can increment; etc. The framework doesn’t need to use of the latest and greatest language features of every new version of PHP, but make sure it’s not using deprecated features. Client’s don’t care about implementation choices (and rightfully so), so errors and warnings in the log files triggered by a framework will reflect poorly on your application, your developers, and your organization… not the developers of the framework.

与必须处理浏览器和平台的不同组合JavaScript程序员相反,PHP程序员通常拥有编写将在已知环境中运行的应用程序的奢望,但是PHP环境仍然可以改变。 操作系统可以升级; PHP版本号可以增加; 等等。该框架不需要使用每个新版本PHP的最新和最出色的语言功能,但请确保它没有使用不推荐使用的功能。 客户不在乎实现的选择(理所当然地如此),因此框架触发的日志文件中的错误和警告将严重影响您的应用程序,开发人员和组织,而不是框架的开发人员。

哪些商业因素正在影响我的决定? (What business factors are influencing my decision?)

If you’re a small business and want to impress a particularly large business during your negotiations, you may be forced to choose a framework that their development shop prefers. Such a scenario plays into the choice to use a particular framework all too often (I’ve actually seen a PHP application that uses not one but three different frameworks precisely because of this reason). The subsequent consequences can be good or bad, and it may be something you have no control over, but it’s something worth bearing in mind.

如果您是小型企业,并且想在谈判中给特别大的企业留下深刻的印象,那么您可能会被迫选择他们的开发商店喜欢的框架。 这种情况经常导致选择使用特定的框架(由于这个原因,我实际上已经看到一个PHP应用程序不使用一个而是三个不同的框架)。 随后的后果可能是好事,也可能是坏事,这可能是您无法控制的事情,但需要牢记。

Not every application needs to be written using a framework. But if you’ve decided that yours does, then it’s beneficial to compare your needs against the features and benefits of the various framework offerings. It may be a framework you’re already familiar with, or it may be a new one, but only through objective analysis can you be certain it’s truly the best fit.

并非每个应用程序都需要使用框架编写。 但是,如果您决定这样做,那么将您的需求与各种框架产品的功能和优势进行比较将是有益的。 它可能是您已经熟悉的框架,也可能是新框架,但是只有通过客观分析,您才能确定它确实是最合适的。

Image via Fotolia

图片来自Fotolia

翻译自: https://www.sitepoint.com/6-things-to-consider-when-choosing-a-framework/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值