wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes facade pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "facade pattern " Watch "facade pattern " New topic
Author

facade pattern

Maksym Odintsov
Greenhorn

Joined: Jan 22, 2009
Posts: 11
Hi guys. I wanted to ask whether I need to implement this pattern in my case or could I live without it ?
My interface for the data class provides following lock method

>>public long lock(int recNo) throws RecordNotFoundException;

So in order to throw recordnotfoundexception I have to access the database file. And I think locking class in facade pattern must provide only locking, but not accessing the database.
If I will not throw this exception in the lock method, than delete and update methods will have to unlock record before throwing RecordNotFoundException. If they will not unlock the record then the exception will be trown and threads that have been already locked will stay locked forever. So in this case my data accessing class will be using unlock method from the lockmanager class.

So in both cases one class in facade pattern will have to use functionallity of another class.
So can I do it all in one class without this facade pattern ?
Kevin Florish
Ranch Hand

Joined: Jan 06, 2009
Posts: 163
Hi Maksym.

I didn't use a seperate class for locking.

My lock and unlock methods are done as part of my Data class implementation, I dont provide a sperate lockManager class as I feel its unnecessary for the project.

Java5 Tutorials | Java6 Tutorials | HTML/CSS Tutorials | JavaScript and jQuery Tutorials
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: facade pattern
 
Similar Threads
Need advice on the Data class
More on locking
Locking strategy with singleton
Finished my project here are my choices and I would like some feedback before I hand it in.
lock(int recNo) throws RecordNotFoundException