aspose file tools*
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
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: 176
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: facade pattern