GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes modularising code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "modularising code" Watch "modularising code" New topic
Author

modularising code

Mohit Sinha
Ranch Hand

Joined: Nov 29, 2004
Posts: 125
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.

Mohit
 
wood burning stoves
 
subject: modularising code