Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

missing criteriaFind method

 
Manish Kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Data class which i have got does not contain the criteriaFind method like lock() and unlock().
Is it same with all of you??
please reply.
Thanks.
regards
Manish
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep that is right... I added mine right in the Data class... I believe others have put it in their local and remote classes, but it is the same code for both, which is why I just added it to my Data class.
I would be interested to hear if others did it differently.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nate,
I actually diverged somewhat from the instructions and neither modified nor extended the Data class. Instead I created composites using the Builder Pattern. I created an interface called DataSearch which contained one method: criteriaFind. So remote and local composites had a reference to a DataSearch implementation. Doing it this way makes it easy to add more robust searching facilities in the future without breaking any existing clients.
Michael Morris
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,
Will you be penalized for this by trying to divert from the instructions. The instructions says
You may do this by modification or subclassing, but you should document the approach and reason for your choice.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amish,
I guess not. I made a 154 losing only one point on documentation. That tells me that the examiner agreed with my argument that composition is a better overall design scheme than either inheritance which can cause you to get locked in to an inflexible static design or modification which risks the introduction of bugs into working code. So the moral is if you firmly believe you have a better solution and can sell that solution then go for it.
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic