软件项目的模块化有多重要

发布于 2024-08-02 01:41:07 字数 102 浏览 8 评论 0原文

模块化在软件项目中显然很重要,但我想知道人们对它的重要性以及它重要的原因的看法。 自从我问这个问题以来,我显然有自己的想法,但将其视为应该模块化软件项目的原因的“共同头脑风暴”......

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

乖乖公主 2024-08-09 01:41:07

我们人类在一次性解决所有复杂问题方面是有限的。 然而,为了解决大问题,我们有能力将一个复杂的问题分解为许多(可能非常大)不太复杂的单独问题。

这从根本上推动了“重用”、“关注点分离”、“更容易维护”等答案。

无论是一个人分解一个复杂的问题来逐个解决,还是一组人分解它来分配复杂性,所有这些原因都是正确的。

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.

策马西风 2024-08-09 01:41:07

我认为主要方面之一是重用。 当您以模块化方式构建事物时,几乎不会出现这样的情况:“哦,我以前已经这样做过,但是要使用它,我还必须获得这个和这个功能,这与我的应用程序完全无关”。

而且,它更容易理解。我无法同时在脑海中记住大量的事情。 当代码是模块化的时,就更容易建立一个本身有意义的事物“区域”。 一旦这个区域变得很小,我就能把它理解为一个整体,而不是它的一部分。

最后,当事情变得更小时,更容易测试和维护。此外,一旦测试只测试应用程序的一小部分,就能更快地指出错误所在。

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.

笔落惊风雨 2024-08-09 01:41:07

我将代码放入不同模块的主要原因:

  • 关注点分离:我觉得如果将类组织到单独的模块中,则更容易限制不同级别或不同任务的类内部知识。 如果内部结构隐藏得很好,那么依赖内部结构只会让人感觉更“肮脏”。
  • 更容易维护较小的组件:我通常发现,如果我正在处理代码文件较少的项目,那么与包含数百个文件的项目相比,开发环境的响应速度更快。
  • 防止命名空间冲突:当正确模块化时,例如在 Java 中使用命名空间,您可以为相同的功能使用相同的函数名称,而不必担心 Foo 组件中的 printout() 函数会与Bar 组件中的 printout() 函数。
  • 安全问题的分离:当一个组件踩到另一个组件的脚趾时,更容易将潜在的损害降到最低。 根据所使用的技术,您可以限制每个模块在内存中的播放位置。

My main reasons for putting code into different modules:

  • Separation of concerns: I feel that it is easier to limit the knowledge about the internals of classes on different levels or with different tasks if they are organized into separate modules. It simply feels more "dirty" to rely on internals if they are well hidden.
  • Easier to maintain smaller components: I usually find the development environment to be more responsive if I am working on a project with fewer code files, than if the project contains hundreds and hundreds of files.
  • Prevention of namespace clashes: When properly modularised, e.g. using namespaces in Java, you can have the same function name for the same functionality without having to worry that the printout() function in the Foo component will clash with the printout() function in the Bar component.
  • Separation of security concerns: It is easier to minimise the potential damage when one component steps on the toes of another component. Depending on the technology being used you can limit where each module can play in memory.
伪心 2024-08-09 01:41:07

模块化和解耦很重要,原因有很多,其中一些是:

  • 重用:重用专用于特定目的的软件模块要容易得多
  • 管理复杂性:处理解耦模块(编写代码、调试、维护等)可以让您专注于某个特定目标领域问题,而不会被应用程序或软件系统的其他方面分散注意力。

Modularization and decoupling are important for many reasons, some are:

  • Reuse: It is much easier to reuse software modules that are dedicated to specific purposes
  • Managing Complexity: Working on decoupled modules (writing code, debugging, maintaining etc) keeps your focus on a certain domain problem without being distracted by other aspects of the application or the software system.
夏九 2024-08-09 01:41:07

它也可以被视为应用程序架构的基本活动,其中:

  • 采用一些业务和功能规范
  • 并将主要功能分组为 启动

这就是为什么“金融投资组合计算”实际上会分为:

  • 计算模块
  • 调度程序模块(因为投资组合太大而无法在一台服务器上计算)
  • 器模块(引导所有计算)
  • GUI(查看实际发生的情况)

加上几个横向的:

  • KPI 日志记录
  • 异常管理

将这种功能需求视为一个大的整体模块将迫使开发人员实现所有子例程按顺序作为一个整体。
而有了清晰的应用程序架构,您就可以开始处理更通用和横向的模块,同时仍然完善其他更面向业务的模块。

它还迫使您定义更多接口,并分析不同模块必须解决的内部通信问题(直接 n 对 n 类型?总线?...)

It can also be viewed as a basic activity of Application Architecture which:

  • takes some business and functional specification
  • and group the major functions into applications while identifying non-functional modules and pure technical transversal module

That is why a "financial portfolio computation" will actually be divided into:

  • a computation module
  • a dispatcher module (because a portfolio is too big to be computed on one server)
  • a launcher module (to pilot all the computations)
  • a GUI (to see what is actually going on)

Plus several transversal ones:

  • KPI logging
  • Exception management

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?, ...)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文