• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on design pattern

 
Kumar Ala
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some basic doubt in the following question.
Source:ePratize Labs

You are working as a System Architect and would like to build a Next Gen. code review tool for Java EE applications.Your boss wants to release different code review tools editions,and therefore you want to make few changes in the logic to suit different editions.

select the design pattern that helps to make few logical changes in a class that can be used in many editions.

1)Strategy
2)Template
3) Factory
4) Bridge
Answer given is Template pattern.

I would think that strategy is also possible as question says that "few logical changes in a class that can be used in many editions." something like changing the algorithm will be suitable for this. Can someone explain why not strategy ..?
 
deepak adlakha
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I re-read the question two/three times and here is the catch in this phrase

"you want to make few changes in the logic to suit different editions"

Few changes in logic to suit different editions. With Template pattern only changes which are required to suite that particular version can be done.

There are only two option which we can think of from the given options "Strategy or template". But by reading the question phrase above, i think template pattern wins over strategy Because all common code can be placed in the base and only minor/few changes can be done in the subclass for each version or some other requirement without touching the base class or core template.

From implementation point of view strategy is also possible, but then each algorithm needs to contain its whole logic. I think the catch word in question is "few". But yes it can be debated between these two patterns like where will be less/few changes.

 
Kumar Ala
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you might be right Deepak...thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic