Figure 2. The Stable Package Concept
In this case, the package "parser" contains classes
implementing the parsing of different data formats such as XML data etc. In
most cases, the parsing implementations are likely to be stable. Thus other
packages such as "trader" and "registration" can depend on "parser" package,
which is more stable.
The question is how do we know that we have arrived to the
correct package design that is compliant with SDP? One way to measure the
stability factor of any package is based on the incoming and outgoing
dependencies for a particular package. Consider this example of package dependency
in Figure 3.
Figure 3. Package Dependency Diagram
In this diagram, package A, B and C has outgoing
dependencies on package D. The package D has outgoing dependency on package E.
The formula for calculating the stability factor is:
I = Ce/(Ce +Ca)
Where
Ca is the number of
incoming dependencies for a particular package.
Ce is the number of
outgoing dependencies for a particular package.
I is the stability factor.
As I approaches 0 the package becomes more stable because
this implies that Ce is 0 and there is no outgoing dependency at all. On the
other hand, if I approaches 1, the package becomes more unstable.
In our example, for package D:
Ca = 3, the number
of incoming dependencies
Ce=1, the number of outgoing dependencies
So I = 1/(1+3) = 0.25.
Whereas for package A,
Ca = 0, the number of incoming dependencies
Ce = 1, the number of outgoing dependencies
So I = 1/(1+0) = 1
This result implies that package D is more stable than
package A. This also implies that package A is easier to change than package D.
The SDP says that packages with less stability should depend
upon the packages with more stability. In other words, if package X has
stability factor s1 and package Y has stability factor s2, then package X
should depend on package Y if s1>s2.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.