我要试着写一些关于软件耦合和内聚的想法,但我不确定它们是否意味着任何实际的东西。所以,如果你想用例子来解释你的答案,请使用简单的代数表达式想象代数是一个连续的编程语言所以我们都可以理解you're谈论...¿关于耦合的意义是否正确?
所以在这里是我想相信(¿这是正确的?):
'Implementation of A with Low Cohesion
'(Coincidental cohesion because there is no
' good reason or need to group the functions
' in this way)
a(x) = 2x + 1
b(x) = 3x + 2
r(x) = a(x) + b(x)
...
'Implementation of A with High Cohesion (Almost Atomic)
r(x) = 5x + 3
...
'Implementation of A with Low Cohesion too
a(x) = 2x + 1
r(x) = a(x) + 3x + 2
...
'Implementations of A with Functional Cohesion
a(x, y) = x * y 'Groups multiplication
b(x, y) = x + y 'Groups addition
r(x) = b(a(5,x), 3)