• 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

modifying vs. Extending the Data class

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In design choices documentation, we need
write something for modifying vs. Extending the Data clas. but what is modifying? and what is
Extending?
My explain for modifying is that just changes the code and does not change signiture of the class method.
Extending means change signiture of the class, Add method or
subclass from interface like IData?
please help me!
thanks
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


... but what is modifying? and what is
Extending?
My explain for modifying is that just changes the code and does not change signiture of the class method.
Extending means change signiture of the class, Add method or
subclass from interface like IData?
please help me!


Well modifying could involve the changing of signatures, the overloading of methods, the removal or addition of methods, etc. Some of these things would not be wise for the most part but still come under the definition of modification.
Extending involves inheritance. In other words, you create a subclass of Data. You then add new methods, overload and override methods and add new state.
Hope this helps,
Michael Morris
 
Forrest Xu
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replay!
my Data class
1) implements an interface IData.
2) no any subclass of Data class.
For 2) it is obviously modifying.
how about 1) is it Extending?
thanks
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Implementing an interface is not extending in the truest sense. It is the agreement by the class to fulfill a contract. If the interface does not add any methods that Data does not already implement, then you are obviously not extending Data. If it does require Data to add methods, then you are really modifying and not extending Data.

Hope this helps,
Michael Morris
 
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
Hi java2de XIU
Where have you been? Long time since you last posted. How is your assignment going?
Meanwhile I became a bartender so I get to harass you regarding your log in name.
Can you change it to your real name?
You can change it
here.
Thanks! and good to see you back.
Mark
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark & Michael,
Seems in my design, it's neither extending or modifying the data class(except fixing the deprecated methods).
What I did was just using a adapter pattern where the data class remain unchanged and I have a single interface for both LocalDataAccess & RemoteDataAccess to implement and both of them are just wrapping an instance of Data class into their constructor and redirect each method call to Data. Moreover, the interface defined only those existing public methods in Data class, not defining any additional methods. The criteriaFind was coded in the Facade class at client side. So essentially I'm not extending or modifying my Data class. What should I write in my design choices then?? Please give me some idea.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi CyJenny,
I did essentially the same thing you did. Just describe what you did and give your reasoning for doing it that way. My arguments were that composition is a better overall design scheme than inheritance and that you are better off not modifying working code.
Michael Morris
 
Forrest Xu
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
I changed my name now.
I am in Canada.
I almost have no time to develop the assignment.
I need to work to support my family. The work for company and for home are all very busy. So I only can give a very little time to the assignment.
Now the application seems work, but need to write the documentation.
Thank you for your web site.
Forrest
 
reply
    Bookmark Topic Watch Topic
  • New Topic