File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Factory pattern with cookies Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Factory pattern with cookies" Watch "Factory pattern with cookies" New topic

Factory pattern with cookies

Ken Boyd
Ranch Hand

Joined: Dec 10, 2003
Posts: 329
Is it okay to use factory pattern mention in Andrew book with cookie in assignment? I have design with both options with and without factory pattern in RMI but factory one runs in flying color under all test for locking where as non-factory pattern model for RMI finds some problem in some test case.
Even if I use factory pattern for RMI I have always use cookie for lock-unlock-update-delete method. Do you guys think I might loose marks for network or OO design for using factory pattern where cookies are available for locking but threads are never use or hashcode for locking purpose??? Please comment.

// Locks a record so that it can only be updated or deleted by this client.

// Returned value is a cookie that must be used when the record is unlocked,

// updated, or deleted. If the specified record is already locked by a different

// client, the current thread gives up the CPU and consumes no CPU cycles until

// the record is unlocked.

public long lock(int recNo) throws RecordNotFoundException;

Thank you,
[ May 26, 2007: Message edited by: Ken Boyd ]

Ken Boyd
Ranch Hand

Joined: Dec 10, 2003
Posts: 329
Can someone comment!!!
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918


The remote factory has also other advantages than the client identification. I don't think that you'll lose point if you use it but what is more important you must justify what you use it.


rinke hoekstra
Ranch Hand

Joined: Apr 06, 2007
Posts: 152
Hi Ken,

I'm exactly at the same stage in my assignment, and was, just like you, doubting about this. I think my ideas are going in the direction of not using the factory, as the assingment tells you to keep things as simple as possible, and it looks a bit like overkill to me.

However, enough people seem to be using it, and if your version with the pattern is working better than the one without, I wouldn't give it more time, and just use the one with the pattern.

_ _ ________________________ _ _ <br /> <br />Just SCJP (but 93%)
Ken Boyd
Ranch Hand

Joined: Dec 10, 2003
Posts: 329
Thank you guys as I was stuck with this issue for sometime. I will go with factory pattern as you can use it for future enhancement for crash client detection and returning multiple objects instead of DB only at this time. At the same time it cost you in performance a little bit i.e. more threads and little hit on performance but that won't be big deal since it is pilot program.

I agree. Here's the link:
subject: Factory pattern with cookies
jQuery in Action, 3rd edition