9

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

4

5 回答 5

5

在一次处理复杂问题方面,我们人类是有限的。然而,我们有能力将一个复杂的问题分解为(可能非常大)数量不太复杂的单个问题,以便解决大问题。

这从根本上推动了诸如“重用”、“关注点分离”、“更易于维护”之类的答案。

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

于 2009-08-10T17:17:38.207 回答
4

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

此外,它更容易理解。我不能同时在脑海中记住很多事情。当代码是模块化的时,就更容易建立一个本身有意义的事物“区域”。一旦这个区域趋于小,我可以将其理解为整体而不是部分。

最后,当事情更小时,更容易测试和维护。此外,一旦他们只测试应用程序的一小部分,您的测试可以更快地指示错误所在。

于 2009-08-10T17:04:01.277 回答
2

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

  • 关注点分离:我觉得如果将它们组织成单独的模块,则更容易限制对不同级别或不同任务的类内部知识的了解。如果内部组件隐藏得很好,那么依靠内部组件只会感觉更“肮脏”。
  • 更容易维护更小的组件:如果我正在处理一个代码文件更少的项目,我通常会发现开发环境的响应速度比项目包含数百个文件的情况要好。
  • 防止命名空间冲突:当适当模块化时,例如在 Java 中使用命名空间,您可以为相同的功能使用相同的函数名,而不必担心 Foo 组件中的 printout() 函数会与条形组件。
  • 安全问题的分离:当一个组件踩到另一个组件的脚趾时,更容易将潜在的损坏降至最低。根据所使用的技术,您可以限制每个模块可以在内存中播放的位置。
于 2009-08-10T17:04:00.823 回答
1

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

  • 重用:重用专用于特定目的的软件模块要容易得多
  • 管理复杂性:处理解耦模块(编写代码、调试、维护等)让您专注于某个领域问题,而不会被应用程序或软件系统的其他方面分心。
于 2009-08-10T17:23:17.757 回答
0

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

于 2009-08-10T17:43:30.900 回答