• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FBN: Modifying vs. Extending the Data class

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic