CSC/ECE 517 Fall 2009/wiki3 18 301: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 2: Line 2:
----
----


The ''instability'' of any package can be calculated using the following formula:
The Stable Dependencies Principle (SDP) states that “a package should always depend upon packages that are more stable than it is.” Ideally, the direction of dependencies should go from high volatile to more stable packages.


'''I (instability) = Ce / ( Ca + Ce )'''
The instability of any package can be calculated using the following formula.
 
I (instability) = Ce / ( Ca + Ce )


In this formula:
In this formula:


Ce – the number of other modules that our package requires to operate. In other words, this is an indicator of package ''independence''.
Ce – the number of other modules that our package requires in order to operate correctly. In other words, this is an indicator of package independence.
 
Ca – the number of packages that can be viewed as “dependents“, i.e., “depend upon classes within the package”. This is an indicator of package responsibilities.
 
Therefore, in order for a package to be completely independent and also stable, it should not be dependent upon other packages.
 
For example, let’s look at the following component diagram:
 
<image1>
 
The Wheel class in this example is shown as not dependent on any other module.
 
Using the above formula:
 
I(W) = 0 / ( 3 + 0 ) = 0
 
I(W) has the instability of zero. In other words, even though the Wheel class is “responsible” for three classes (Ca=3), it is not dependent upon any of them (Ce = 0), thus resulting in a stable package.
 
Respectively, instable or irresponsible packages would have the instability of 1, as shown below:


Ca – the number of packages that can be viewed as “dependents“, i.e., “depend upon classes within the package”. This is an indicator of package ''responsibility''.
<image2>
In this case, the Car class does not have any dependent classes (Ca = 0), yet itself depends upon three classes Wheel, Engine, and Suspension (Ce = 3).


Therefore, in order for a package to be completely ''independent'' and also ''stable'', it should not be dependent upon other packages.
Let’s calculate the instability:


Using the formula: '''I = 0 / ( Ca + 0 ) = 0''', has the instability of zero.
I(C) = 3 / ( 0 + 3 ) = 3 / 3 = 1


Respectively, ''instable'' or ''irresponsible'' packages would have instability of 1 as shown below:
The instability of 1 indicates a high level of volatility of the Car module.


'''I = Ce / ( 0 + Ce ) = Ce / Ce = 1'''
So how do we know whether a certain component design follows the SDP?

Revision as of 05:12, 18 November 2009

Topic: Stable Dependencies Principle


The Stable Dependencies Principle (SDP) states that “a package should always depend upon packages that are more stable than it is.” Ideally, the direction of dependencies should go from high volatile to more stable packages.

The instability of any package can be calculated using the following formula.

I (instability) = Ce / ( Ca + Ce )

In this formula:

Ce – the number of other modules that our package requires in order to operate correctly. In other words, this is an indicator of package independence.

Ca – the number of packages that can be viewed as “dependents“, i.e., “depend upon classes within the package”. This is an indicator of package responsibilities.

Therefore, in order for a package to be completely independent and also stable, it should not be dependent upon other packages.

For example, let’s look at the following component diagram:

<image1>

The Wheel class in this example is shown as not dependent on any other module.

Using the above formula:

I(W) = 0 / ( 3 + 0 ) = 0

I(W) has the instability of zero. In other words, even though the Wheel class is “responsible” for three classes (Ca=3), it is not dependent upon any of them (Ce = 0), thus resulting in a stable package.

Respectively, instable or irresponsible packages would have the instability of 1, as shown below:

<image2>

In this case, the Car class does not have any dependent classes (Ca = 0), yet itself depends upon three classes – Wheel, Engine, and Suspension (Ce = 3).

Let’s calculate the instability:

I(C) = 3 / ( 0 + 3 ) = 3 / 3 = 1

The instability of 1 indicates a high level of volatility of the Car module.

So how do we know whether a certain component design follows the SDP?