wood burning stoves*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Subclass , Enhance or Adapt ? - Help Please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Subclass , Enhance or Adapt ? - Help Please" Watch "Subclass , Enhance or Adapt ? - Help Please" New topic
Author

Subclass , Enhance or Adapt ? - Help Please

Rajesh Matti
Ranch Hand

Joined: Jan 07, 2002
Posts: 121
Though I do not have any problems implementing locking in whichever way it is required, I want to seek your advice.
My assignment says "Part of your assignment will be to enhance the Data class. You may do this by modification or subclassing, but you should
document the approach and reason for your choice. ".
I did not subclass the Data class. I modified it to implment the criteriaFind(). I have an adpater class for the Data class and this adapter does locking and unlocking with the help of the LockManger. Every client will get a seperate instance of adapter which has a reference to single instance of the Data object.
First of all, are there only two choices which are 'accepted' for locking, either subclass or modify ?. If yes, ignore the next paragraph please.
If this is okay, now, if I get a question like "Did you subclass or modify the data class to implment locking ?' how do I answer ?.
[ March 15, 2002: Message edited by: Rajesh Matti ]
Krishna Varma Adluru
Ranch Hand

Joined: Nov 24, 2001
Posts: 55
Rajesh,
I myself decided to "Adapt" the Data class for
locking and Unlocking ...
If I get a question like that in the exam,
I would answer like this :
"I neither modified or extended the Data class ...
I used Composition/Adapter ... blah ... blah ..blah .."(Reasons for Adaption)
But, I am not an SCJD yet ...I would appreciate
if someone with an SCJD and who took this approach
helps us ...
Regards,
Krishna Varma
Rajesh Matti
Ranch Hand

Joined: Jan 07, 2002
Posts: 121
Krishna- That is exactly I would answer, but look at the question, if you are asked 'Did you subclass or modify', I assume the answer to be one word.
ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
Hi
I was thinking of modifying the Data class for implementing the lock / unlock because I need to have some additional methods for lock / unlock.
I reached this decision after posing my query for lock and unlock on this forum.
I personally would not like to touch any classes given by the Sun and rather would extend the class to give whatever desired behaviour I want for a method.
Thanks
-- Ravindra


SCJP, SCJD, SCWCD, SCBCD, SCEA
Rajesh Matti
Ranch Hand

Joined: Jan 07, 2002
Posts: 121
janapareddy - The issue is not whether to modify or subclass the dataclass, but, is about doing neither of them !!!
[ March 15, 2002: Message edited by: Rajesh Matti ]
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Rajesh, I believe you have modified the Data class right? You see when you change the deprecated methods from within Data or add the criteriaFind functionality, you are automatically modifying data. You woudnt have to do this if you extended Data and deprecated the faulty methods and provided your criteriaFind in the extended class.The methods lock and unlock need not really be concerened with the question. I beleive you have modified and not extended Data and you should state the same. I doubt they will ask you a question like "Did you implement locking by modifying or extending data?". Anyway this is my 2c. Enjoy bud.


Never be satisfied with anything less than the best and you will surely pass the test...
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
How are you handling the existing code that uses deprecated methods? If you aren't touching Sun's code then what are you doing?
I suppose you could extend the Data class and override the methods, but then there's still code that uses deprecated methods. If you just fix the methods of Data that call deprecated methods and subclass it to handle locking or criteriaFind, then haven't you modified *and* extended the class?
Seems to me that if part of the task is to remove calls to deprecated methods you MUST modify the Data class, however slightly. And, technically, if you add the required javadoc comments you've modified it even more - at least that's what any decent revision control system would tell you.
It's a puzzle I've yet to find a clear answer for . Maybe there isn't one and anything you can make a good enough case for is acceptable.
:roll:
If there's anybody with an answer they wan to debate, please put it out here so we can see who shaved the barber.

Originally posted by janapareddy ravindra:
I personally would not like to touch any classes given by the Sun and rather would extend the class to give whatever desired behaviour I want for a method.

:roll:


SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Rajesh Matti
Ranch Hand

Joined: Jan 07, 2002
Posts: 121
Kalichar- While I appreciate your 2 cents, dude, I am talking in the context of lock mechanism, i did change the data class to implement criteriaFind(), changing data class to fix the deprecated methods do not qualify for subclassing or enhancingc the data class. I think modifying should not be taken literally in programmer's world, rather should be taken towards enhancing or subclassing. Hope you understand better...
Rajesh Matti
Ranch Hand

Joined: Jan 07, 2002
Posts: 121
Burk - When I said modify or subclass it applies to criteriaFind() and lock mechanism. Hoping that you understand what I meant, please give your opinion, I am not for a debate here, as I am not interested in one.
Thanks,
-Rajesh
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Well Rajesh another of my 2c. There is a part of the exam requirements doc that leaves certain areas open for your own design. Just because modifying or extending Data are common choices to handle locking mechanism neeed not meet they are the only way. If I were you, I'd stand by my descision and say, "I neither modified Data nor did I extend it. Instead I provided an Adapter that handled the locking mechanism for the database." If you didnt modify or extend Data to design ur app, well that is definitely a design choice made by you and as long as you can justify why u did it, I am sure the examiner would appreciate it. Hope this helps. Good luck dude...enjoy.
Rajesh Matti
Ranch Hand

Joined: Jan 07, 2002
Posts: 121
Thanks Kalichar for all of your 4cs ...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Subclass , Enhance or Adapt ? - Help Please
 
Similar Threads
modification or subclassing data - is this strictly one or the other ?
stuck by lock
Design Choice...(Post your opinions)
Adapter pattern
Definition of a record locked for modification