2

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?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
aillusions
  • 194
  • 1
  • 15
  • 3
    It's telling you that the term `package` as used in the document has *nothing* to do with java packages (in terms of the keyword). As for the second bullet-point; I don't actually know what you're asking. The [Wikipedia entry for Namespace](http://en.wikipedia.org/wiki/Namespace) explains it in a non-programming context. There's a bunch of good practices out there, but there are no *principles* of namespaces per se. – Anya Shenanigans Sep 19 '14 at 12:13
  • The issue is that there is another article (http://www.objectmentor.com/resources/articles/granularity.pdf) which describes exactly same six packaging principles. But it says: in this article we will ...refer to these higher order granules as “packages”. ...The term “package” is common in Ada and Java circles. In those languages a package is used to represent a logical grouping of declarations that can be imported into other programs. So the question is: **can we apply REP, CRP, CCP ... principles to java NS packages as well as to java archives (JARs)**? Thanks – aillusions Sep 19 '14 at 14:04

1 Answers1

0

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.

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121