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 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

facade pattern

Maksym Odintsov

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: 181
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:
subject: facade pattern
It's not a secret anymore!