Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Modify/Extend Data

 
Vikas Sood
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
I am currently documenting assignment, I have moified my Data class to include criteriaFind in it.
I am documenting pros and cons of this .My reasons for not exending Data are based on the fact that, the role of Data class in the assignment is to provide basic database services.And a search mechanism should be by default part of it and not an extension.
And also generally we extend a class to add extra functionality over and above the basic functionality of a class. That is in the current scenario of Data class ,if need to enhance it so as to include multiple database files handling through a single Data object, we would go in for extending this class for adding this functionality to it.
Other scenarios for modification could be enhancement to data handling capabilities or adding of locking and unlocking mechanism in the Data class.
What can be the other reasons of either extending or modifing a class.
Kindly comment.
VikasSood
 
Miguel Roque
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vikas.
You mention them all .
Miguel
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vikas
You might also want to extend a class if you needed different functionality, but could not change the original. For example, if you wanted the lock method to always return a cookie, but could not change the Data class because existing programs would then fail. (For example: the deprecated methods in the Java library).
Likewise, you might have to extend a class if some "basic functionality" is missing, but you don't own the class. For example, if you needed to add a criteriaFind method, but the original programmer is still making changes to the Data class - in this case you cannot add your method, as it will be overwritten the next time the other programmer updates their version of Data class.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic