File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

whats the pros and cons of modifying and sublassing data

 
Lisa Foster
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Lisa
 
Catherine McManus
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't got very far with my project yet, but I can't at the moment see any reason for subclassing data. The additions required do not replace or change any existing methods.
I would be interested to hear from anyone who could argue in favour of subclassing.
Catherine
 
ruilin yang
Ranch Hand
Posts: 334
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I favor to modify rather than subclass.
However, the advantage of subclassing is:
1) small code, so easy to read.
2) better performance in case of object lock (parent and subclass
both have synchronized methods)
Please make more comments on the topic or correct mine.
Ruilin
 
Glenn Opdycke-Hansen
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Modify when there is a problem with the class--bad method signature, import statement wrong, ...
Extend to create a derived class that "is-a" base class (to use the oo terminology), but has variations in the method behavior.
For example, I created a DataClientLocal class that extends the DataClient class. It has the same methods, but instead of accessing the database remotely, it uses local access.
------------------
--glenn
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic