软件项目的模块化有多重要
模块化在软件项目中显然很重要,但我想知道人们对它的重要性以及它重要的原因的看法。 自从我问这个问题以来,我显然有自己的想法,但将其视为应该模块化软件项目的原因的“共同头脑风暴”......
Modularization is obviously important in software projects, but I want to know people's opinions on how important and for what reasons it is important. I've obviously got my own ideas since I'm asking this, but think of it like a "common brainstorm" of the reasons one should modularize one's software projects...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我们人类在一次性解决所有复杂问题方面是有限的。 然而,为了解决大问题,我们有能力将一个复杂的问题分解为许多(可能非常大)不太复杂的单独问题。
这从根本上推动了“重用”、“关注点分离”、“更容易维护”等答案。
无论是一个人分解一个复杂的问题来逐个解决,还是一组人分解它来分配复杂性,所有这些原因都是正确的。
We humans are limited when it comes to grasping complex problems all at once. However, we are gifted in the ability to decompose a complex problem into a (possibly very large) number of individual problems that are not too complex in order to tackle the big problem.
This is fundamentally what drives answers like "reuse", "separation of concerns", "easier maintenance".
All of these reasons are true whether it is one person breaking down a complex problem to tackle piece-by-piece, or if it is a team of people breaking it down to distribute the complexity.
我认为主要方面之一是重用。 当您以模块化方式构建事物时,几乎不会出现这样的情况:“哦,我以前已经这样做过,但是要使用它,我还必须获得这个和这个功能,这与我的应用程序完全无关”。
而且,它更容易理解。我无法同时在脑海中记住大量的事情。 当代码是模块化的时,就更容易建立一个本身有意义的事物“区域”。 一旦这个区域变得很小,我就能把它理解为一个整体,而不是它的一部分。
最后,当事情变得更小时,更容易测试和维护。此外,一旦测试只测试应用程序的一小部分,就能更快地指出错误所在。
I think one of the main aspects is reuse. When you build things modularly, there's hardly things like: "Oh, I've already done this before, but to use it, I'll also have to get this and this functionality, which has absolutely nothing to do with my application".
Also, it is easier to understand. I can't keep tons of things in my mind at the same time. When the code is modular, there's easier to establish an "area" of things that makes sense in themselves. And once this area tends to be small, I can understand it as whole rather than pieces of it.
Finally, when things are smaller, it is easier to test and maintain. Also, your tests indicate faster where the error is, once they will test only a small part of the application.
我将代码放入不同模块的主要原因:
My main reasons for putting code into different modules:
模块化和解耦很重要,原因有很多,其中一些是:
Modularization and decoupling are important for many reasons, some are:
它也可以被视为应用程序架构的基本活动,其中:
这就是为什么“金融投资组合计算”实际上会分为:
加上几个横向的:
将这种功能需求视为一个大的整体模块将迫使开发人员实现所有子例程按顺序作为一个整体。
而有了清晰的应用程序架构,您就可以开始处理更通用和横向的模块,同时仍然完善其他更面向业务的模块。
它还迫使您定义更多接口,并分析不同模块必须解决的内部通信问题(直接 n 对 n 类型?总线?...)
It can also be viewed as a basic activity of Application Architecture which:
That is why a "financial portfolio computation" will actually be divided into:
Plus several transversal ones:
To treat that kind of functional requirement as one big monolithic module would force the development to implement all the sub-routines in sequence as a all.
Whereas with a clear application architecture, you can begin to work on the more general and transversal modules while still refining the other more business-oriented modules.
It also forces you to define more interfaces, and to analyze the inter-communications issues your different modules will have to solve (direct n-to-n typology? Bus?, ...)