GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes modifying vs. Extending the Data class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "modifying vs. Extending the Data class" Watch "modifying vs. Extending the Data class" New topic
Author

modifying vs. Extending the Data class

Forrest Xu
Greenhorn

Joined: Jan 30, 2002
Posts: 26
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
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451

... 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


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Forrest Xu
Greenhorn

Joined: Jan 30, 2002
Posts: 26
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

Joined: Jan 30, 2002
Posts: 3451
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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
CyJenny Wong
Greenhorn

Joined: May 29, 2002
Posts: 18
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

Joined: Jan 30, 2002
Posts: 3451
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

Joined: Jan 30, 2002
Posts: 26
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
 
GeeCON Prague 2014
 
subject: modifying vs. Extending the Data class