Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FBN: Modifying vs. Extending the Data class

 
Marcos Motta
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My assignment states that the decisions.txt document must include the topic: "Modifying vs. Extending the Data class".
I am having trouble in answering this question because I think that I have done both, modified and extended the class. I have added the method criteriaFind, so I have extended it. I have also modified this class, replacing some deprecated methods and adding code the lock() and unlock() that were provided empty.

Can someone help me clarifying this
thanks
 
Patrick Cobbett
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marcos,
I think that when they refer to modifying or extending it's referring to whether criteriaFind() and lock() are implemented in Data or in a subclass.
 
Mike Southgate
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMO, adding a method to a class is not extending it, rather it's modifying it. Extending it would be creating a second class like this:
class X extends Data {
}
Anything other than that and your modifying the class, IMO.
ms
 
Damian Ryan
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike is right.
Extending refers to creating a subclass.
Modifying refers to altering the existing class.
If your FBN is anything like mine was, you will have deprecated method calls inside private methods.
Ask yourself how you would overcome this in a subclass without cutting and pasting code from the private method in Data.
There are a few other clear reasons why you may want to take one path rather than the other - I won't state them here because you will come across them for yourself.
As with much else in the exam, there is no one right way to do things. There may be quite a few wrong ones but as long as you don't pick one of those and can fight your corner come design choices time and essay exam time, you'll be fine.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic