Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

modularising code  RSS feed

Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I would want to know your thoughts on this.

Currently I have a method which constructs a custom java object and passes on this object to the underlying DAO layer. Now this method is being called by n number of classes and the only difference between each of this call is one String attribute("abc" or "xyz" etc) of the custom java object. Rest of the custom java object attributes remains the same.
I am thinking of modularising this method in the parent class of all these above mentioned child classes. Should i pass the variant string as mentioned earlier as an input parameter to the centralized method and in the body of the method have a switch/case to set the string attribute of the custom object accordingly.
The child classes will call this method accordingly with their respective "string" value.

Is this right design choice for the problem in context.

If you have better ideas do post your thoughts.

Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!