Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Whizlab's Q ??

 
Debanjana Dasgupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
For this Q

You have invented the next generation spell checker that can learn from and automatically correct the common typing mistakes of an individual user. You have already sold licenses to many major software vendors and plan to retire in the sun. However, you are required to make slight changes in the logic to suit each software vendor's individual application needs. What design pattern will help you marginally change the logic in a class for use in different applications?
The answer is Template Pattern.
My question is why not Strategy?
Thanks
Debanjana
 
Stephen Cowell
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your answer is better, but either one is correct. I wouldn't get hung up on that question, the exam is less ambiguous.
 
Debanjana Dasgupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.
I still do not understand where to use Template and when to use Strategy.
They seem to do similar stuff.
Thanks
Debanjana
 
Shankar Ranganathan
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think "Template" is the right one.The important part of this question is "slight changes in logic"
which says that there is a skeleton of the algorithm already and only a few changes to the logic needs to be made.This is ofcourse the template pattern.
Strategy pattern would be more applicable when there is a different set of algorithms and you can implement any one of them using the strategy pattern.
By the by how do you rate the whizlabs questions?

Shankar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic