This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Performance and the fly likes Design suggestions when working with new requirements but old code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Design suggestions when working with new requirements but old code" Watch "Design suggestions when working with new requirements but old code" New topic
Author

Design suggestions when working with new requirements but old code

seena mathew
Greenhorn

Joined: Jun 14, 2009
Posts: 20
I am a newbie to design phase and newbie to the existing working application.
Scenario:
Functionally working code in production, MVC, in house framework since last 10 years
Requirement:
Functionally:
Looks and feel of the few pages has to be changed by using new rich java script library. There is some slight functionality change here and there too but major change is about look and feel.
Design:
It should be reusable code and could be extended for next phase change-which definitely is more changes on to other pages and maybe or maybe not changes to framework (can be struts though not sure)

Question:
Ques1: Java classes: Helper, POJO, Retrieval class : Is it better to modify the existing class or have a new class extend the old class?
My pref: Better to have new class- Large methods in existing class and at some stage the methods can be rewritten ,easy to debug
Ques2: If suggested way is new classes should they reside in a different package hierarchy so as to easily differentiate if one has to move to new framework
Ques3: Are there any recommended books/articles which might help me in understanding designing when working with new and old code better







Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

I believe, this is a migration scenario.

Please find below, my attempt to answer to your questions.
1. Write a new class extending the old one
2. Maintaining the new classes in a different package will definitely help when full scale migration is started
3. You may need to search the Internet for topics/books on "J2EE application migration"


S.D. MADHAN
Not many get the right opportunity !
Geert Pante
Greenhorn

Joined: Feb 03, 2011
Posts: 8
seena mathew wrote:I am a newbie to design phase and newbie to the existing working application.
Scenario:
Functionally working code in production, MVC, in house framework since last 10 years
Requirement:
Functionally:
Looks and feel of the few pages has to be changed by using new rich java script library. There is some slight functionality change here and there too but major change is about look and feel.
Design:
It should be reusable code and could be extended for next phase change-which definitely is more changes on to other pages and maybe or maybe not changes to framework (can be struts though not sure)

Question:
Ques1: Java classes: Helper, POJO, Retrieval class : Is it better to modify the existing class or have a new class extend the old class?
My pref: Better to have new class- Large methods in existing class and at some stage the methods can be rewritten ,easy to debug
Ques2: If suggested way is new classes should they reside in a different package hierarchy so as to easily differentiate if one has to move to new framework
Ques3: Are there any recommended books/articles which might help me in understanding designing when working with new and old code better


"Prefer composition over inheritance" is an old design principle, but I thing it does apply in this case as well. If you need to implement new functionalities in your objects for your javascript library, you could use the GoF Adapter pattern. In Domain Driven Design, a more elaborate approach is called the 'Anti-Corruption Layer'. See e.g. http://www.infoq.com/minibooks/domain-driven-design-quickly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design suggestions when working with new requirements but old code