• 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

Hi Guies , How do you compare the extension VS modification

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To me they are almost the same. If I use extension , I still can have chance to use modification some times later. vice versa.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you extension vs modification has sometimes the same results and sometimes it is different.
Just as a simple example to prove why you have to extend over modification is the situation where there are many apps using this class. If they are expecting a certain implementation, and in your new app that will use this class needs a different implementation, then modifying the class will break the older applications.
Example
I have a Commission class. App1 expects Commission to calculate as (Gross Profit-Costs)/10%, and this happens to be hard coded in the class. (Forget about some OOP ways around this bad design), Now App2 needs to calculate the commission as Gross Profit/5$.
In the Commission class the method calculated has this code. If you modify the class to have the new calculation then App1 will get the wrong results. However, if you extend the class and override the calculate method in the extended class with the new calculation then App1 can still use the Commission class, and App2 can use the NewCommision class without breaking each other.
Hope that helps in some part. There are other reasons in deciding when to do modify vs extend, but I have to get back to work.
Mark
 
Lin Feng
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark.
Why I have this question is because I do not think the extension and modify are enemy. On the other words, even I used modifying at this time, I still can use extension in the future to provide a total different solution. Just for the assignment, both of them should be fine.
Regards
Lin
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It can be used both. Meaning you could defend the choice to modify the Data class to change the deprecated parts, then extend to add lock(), unlock() and criteriaFind().
It is your choice completely, and you just defend your choice in the design.txt document.
Good Luck

Mark
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic