Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design suggestions when working with new requirements but old code

 
seena mathew
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 312
Java MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"
 
Geert Pante
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic