p***p 发帖数: 559 | 1 using Eclipse Mertics http://metrics.sourceforge.net/ to diagnose my code, there is a parameter "instability", what does it mean?
Afferent Coupling (Ca)
The number of classes outside a package that depend on classes inside the
package.
Efferent Coupling (Ce)
The number of classes inside a package that depend on classes outside the
package.
Instability (I)
Ce / (Ca + Ce) |
p***p 发帖数: 559 | 2 it obviously encourages one God class over a group of specialized classes.
Also it would
discourage the use of inner classes.
Can you give me a example to explain it or some resource about it online? |
c*****t 发帖数: 1879 | 3 Hmm, I made a mistake in the original post.
What it measure is how likely your code will be affected by packages
out of your control. The more outside packages it depend on, the less
stable it is (since others may change assumptions, deprecate APIs etc).
So, make it as stable as possible (i.e. close to 0). But you cannot
avoid it often times. But you can have internal layers to specifically
deal with outside packages and thus reduce instability significantly.
【在 p***p 的大作中提到】 : it obviously encourages one God class over a group of specialized classes. : Also it would : discourage the use of inner classes. : Can you give me a example to explain it or some resource about it online?
|
m******t 发帖数: 2416 | 4
While the idea itself might be good, I find it ludicrous to use the number
of classes for the calculation - everything else being equal, it obviously
encourages one God class over a group of specialized classes. Also it would
discourage the use of inner classes.
【在 c*****t 的大作中提到】 : Hmm, I made a mistake in the original post. : What it measure is how likely your code will be affected by packages : out of your control. The more outside packages it depend on, the less : stable it is (since others may change assumptions, deprecate APIs etc). : So, make it as stable as possible (i.e. close to 0). But you cannot : avoid it often times. But you can have internal layers to specifically : deal with outside packages and thus reduce instability significantly.
|
c*****t 发帖数: 1879 | 5 Because you reduce the # of classes depending on outside packages to 1.
Essentially, you can create a layer to redirect calls. Then again all
CS problems can be solved if we introduce a layer :)
【在 p***p 的大作中提到】 : it obviously encourages one God class over a group of specialized classes. : Also it would : discourage the use of inner classes. : Can you give me a example to explain it or some resource about it online?
|
p***p 发帖数: 559 | 6 which is better?
【在 c*****t 的大作中提到】 : Because you reduce the # of classes depending on outside packages to 1. : Essentially, you can create a layer to redirect calls. Then again all : CS problems can be solved if we introduce a layer :)
|
m******t 发帖数: 2416 | 7
LOL, this reminds me of an "old" CS saying: virtual means you never know
where the next byte comes from.
【在 c*****t 的大作中提到】 : Because you reduce the # of classes depending on outside packages to 1. : Essentially, you can create a layer to redirect calls. Then again all : CS problems can be solved if we introduce a layer :)
|
p***p 发帖数: 559 | 8 one God class over a group of specialized classes
i mean thisn sentence
.
【在 m******t 的大作中提到】 : : LOL, this reminds me of an "old" CS saying: virtual means you never know : where the next byte comes from.
|
c*****t 发帖数: 1879 | 9 Agree. It is a quite meaningless number over all :)
would
【在 m******t 的大作中提到】 : : LOL, this reminds me of an "old" CS saying: virtual means you never know : where the next byte comes from.
|
m******t 发帖数: 2416 | 10
For any given Ca > 0, Ce/(Ca + Ce) monotonically increases as Ce increases.
【在 p***p 的大作中提到】 : it obviously encourages one God class over a group of specialized classes. : Also it would : discourage the use of inner classes. : Can you give me a example to explain it or some resource about it online?
|
p***p 发帖数: 559 | 11 Wiki
In object-oriented programming, a God object is an object that knows too
much or does too much. The God object is an example of an anti-pattern.
The basic idea behind object-oriented programming is that a big problem is
broken down into many smaller problems (divide and conquer) and solutions
are created for each of them. If you are able to solve all of the small
problems, you have solved the big problem as a whole. Therefore there is
only one object about which an object needs to know ever
【在 c*****t 的大作中提到】 : Because you reduce the # of classes depending on outside packages to 1. : Essentially, you can create a layer to redirect calls. Then again all : CS problems can be solved if we introduce a layer :)
|