Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

modularising code  RSS feed

Mohit Sinha
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.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!