• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java design for robust software  RSS feed

 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a few dozens helper/utility classes packaged in a jar file. I build applications that use this jar file. From time to time I change this jar and I am always afraid that the changes will break existing applications.
My question is that: are there general rules/guidance that will help make the classes in the jar file more robust?
Thanks.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the packaging principles in Robert Martin's Principles of OO Design blog. These are all about managing dependencies for exactly the kind of problems you are facing.

In short, users of your classes want them to be very stable. The most stable parts of a system should also be the most abstract. The most abstract thing you have to work with is an interface. So, I'd suggest you strive to expose only interfaces to your users.

You used a magic word "utility" in there. Often that hints at classes with lots of static methods. In this case, a class that has all static methods and forwards all method calls to a private instance of some concrete class might be a good idea. Then your all-static-method utility can be very stable, ie you never change it, while the concrete classes can change without breaking the clients. Not as abstract as interfaces, but better than exposing the classes that do the actual work.

It will be important to have way to prove to yourself and to others that a new release doesn't break any existing APIs. A thorough set of automated tests with a tool like JUnit or Fit is a great thing.

Any of that sound interesting?
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stan,

Indeed they are interesting. I have not thought about making utilities more abstract by using separate classes.
I have to study the Principles of OO Design blog.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That blog has a link to the book he calls "ppp" It's one of my top recommendations and covers the patterns there in great detail. There are some case studies that really point out how to use all those ideas, plus how to design and build in a test driven style.
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ppp link gives this page (http://www.objectmentor.com/home) in which 3 books are shown. Which one is the ppp book?
Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!