Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I changed the signature of lock and unlock methods in Data class

 
G.T. Reddy
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
In my FBN application I changed the signature of the lock and unlock methods as
public synchronized void lock(Object owner, int record)
public void unlock(Object owner, int record)
But in the instructions it has been given as "Record locking must be implemented using the methods public void lock(int) and public void unlock(int)".
is it acceptable?.
please clarify me.
 
Bernhard Woditschka
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is not acceptable, as it becomes harder to use the API.
You cannot simply call lock(10); anymore the user of the API now always has to pass in some identity.
I prefer aproaches that somehow behind the scene "detect" the users identity like the thread in local mode or a remote identity in remote mode.
Bern
[ January 18, 2003: Message edited by: Bernhard Woditschka ]
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by G.T.Reddy:
is it acceptable?
If this question means "can I pass with this?" then the answer is "yes". There have been plenty of participants in this group over time who did something similar and passed.
If the question means "is this solution as good as any other?" the answer must be "no". It is possible to fulfil all requirements without changing the method signatures and without really complicating your architecture. That alone would make such a solution preferable in my book -- of course, as pointed out above, the API would also be easier to use that way -- and assessors are likely to rate it higher than the solution you presented.
- Peter
[ January 18, 2003: Message edited by: Peter den Haan ]
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter den Haan:
If this question means "can I pass with this?" then the answer is "yes".


Actually, that is answer is 'maybe'. The Sun people that I've spoken to take a dim view of this sort of thing, even as some of them have let it slide in the past. Will they continue to let it slide?
Maybe.
Generally, it's a good idea not change the signature, because that steps around the problem they had intended for you to solve.

All best,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
[ January 18, 2003: Message edited by: Max Habibi ]
 
Matt Ghiold
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the question means "is this solution as good as any other?" the answer must be "no". It is possible to fulfil all requirements without changing the method signatures and without really complicating your architecture. That alone would make such a solution preferable in my book -- of course, as pointed out above, the API would also be easier to use that way -- and assessors are likely to rate it higher than the solution you presented.

Ok, Peter, you convinced me, im going to go rewrite my backend =). Shouldn't be to bad though.
Thank's for all your insights...
I think I was taking the "pass" route :roll: , instead of the let's kick the sh-t outa this test route.
thanks again!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic