This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

facade pattern  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!