Can we apply the REP, CRP, CCP, etc. principles to Java packages as well as to JARs?

984 Views Asked by At

Uncle Bob's Principles of OOD (http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod) describes:

  • The five principles of class design
  • The six principles of package design (The Release Reuse Equivalency Principle, The Common Closure Principle, etc.)

The article states that:

In this context a package is a binary deliverable like a .jar file, or a dll as opposed to a namespace like a Java package or a C++ namespace.

Does it mean that the 6 "package principles" are not applicable to Java packages (which are defined with the keyword package) at all? Does that mean it would be a mistake to apply them in this manner? If so, could you point out to where such namespace-package principles can be found?

1

There are 1 best solutions below

0
Dave Schweisguth On

Yes, the package principles can be applied to single Java packages, or equivalent groupings of classes (or other single units of software) in other languages.

The first article in Martin's series of articles about package principles, that about the Release Reuse Equivalency Principle, explains that the principles are about groupings of classes. It rather arbitrarily chooses "package" as a name for those groupings, then mentions that that word is used in Ada and Java for specific types of groupings in those languages. I conclude that the principles apply to any grouping of classes, Java packages included.

Others have successfully applied the package principles to Java packages. JDepend calculates metrics based on the package principles for Java packages. I still miss the wonderful tool Optimal Advisor, which displayed those metrics on a package dependency graph as an aid to refactoring. I found both of them useful in identifying packages which violated the package principles and confirming when I'd fixed those violations by refactoring, such as moving classes to the appropriate packages.