my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Modify OR Extend Data class?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Modify OR Extend Data class??" Watch "Modify OR Extend Data class??" New topic
Author

Modify OR Extend Data class??

Bal Sharma
Ranch Hand

Joined: Sep 19, 2001
Posts: 273
HI There:
BK is here again. Light is coming on, but I am not sure 100% what path should I take? I see lots of people are modifying Data class very few people are arguing about extending Data class. If I am not mistaken we get robust code from extending class. I mean, we do not have to worry about if Data class is being used somewhere in other application. I know if it is real life situation NOT for this test.
If I modify Data class I got to submit both their existing Data class and Modified Data Class too. How can I have same two names in one directory? By the way which is easier? I am kind of lazy too. Any suggestions, tips, comments, observation are welcome. BK

[This message has been edited by Bal Sharma (edited November 10, 2001).]
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Do you really have to submit the original Data with your assignment?
Two concepts to keep in mind when deliberating what to do with the Data class: responsibilities, and is-a vs has-a relationships.
A well-designed class has a coherent, clearly defined set of responsibilities. A well-designed system keeps on subdividing (factoring) the problem until it is modeled as a composition of such responsibilities. You need to establish what you think the responsibilities of Data are. That determines which bits of new functionality go into Data, and which bits go into a subclass or another object altogether. For example, isn't locking directly related to multi-user mode? Is providing multi-user facilities part of the responsibilities of Data? The answers dictate what to do with lock() and unlock().
It's so simple in theory: an is-a relationship is modeled using inheritance, a has-a relationship modeled using associations of some kind. Practice is more difficult (IMHO, when doubting between inheritance and association/composition, pick the latter. Inheritance is generally over-used). If you decide to keep networked, multi-user facilities out of Data, does the networked Data need to be a subclass? In other words, is a multi-user Data a type of Data? Or is it a different beast that implements the same interface? The answer is partly dictated by the way you choose to handle client identification.
- Peter
Bal Sharma
Ranch Hand

Joined: Sep 19, 2001
Posts: 273
YES, my assignment instruction read as follows:
When you submit your assignment, you should provide following parts.

  • Full source and object code, including new classes, modified versions of supplied classes, and copies of supplied classes that were not modified. .....
  • Database db.db

  • I have confusion. If I modify Data class how can I have two files with same name inside one directory. Thanks for clarifaction. BK

Ian B Anderson
Ranch Hand

Joined: Jun 26, 2001
Posts: 275
Hello,
It depends how you read the spec. Your spec said:
"...and copies of supplied classes that were not modified..."
Well if you modify it you don't need to send back the original Data class.
Or if you want you could create a directory within your final submission called something like original and put all original code there.
Ian


<a href="http://www.INESystems.com/scbcd/" target="_blank" rel="nofollow">http://www.INESystems.com/scbcd/</a> - SCBCD Exam simulator<br /><a href="http://www.INESystems.com/scbcd/" target="_blank" rel="nofollow">http://www.INESystems.com/scea/</a> - SCEA Exam simulator
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
What Sun means is that if you use a supplied class as-is, you still submit it together with your own classes. If you modify the class, you just submit the modified version. You do not need to submit the unmodified class as well.
What it boils down to is that you need to give them a complete, working set of sources.
- Peter
Bal Sharma
Ranch Hand

Joined: Sep 19, 2001
Posts: 273
Thnaks guys for clarification.
-Bal
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Modify OR Extend Data class??
 
Similar Threads
All Objects always extend "Object"
Lockmanager as inner class
Confused...
Modifying vs. Extending Data class
Passed 138/155