Win a copy of AWS Security 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:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

DB Facade design

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have decided to use a facade to implement the DBAccess interface and have one class to implement locking and another the actual file access.

In the update method in my DBAccess interface there is a lock cookie passed and the only way I can think of is to have logic in my Facade that handles the interaction between locking and reading.

Here is what I'm thinking - just pseudo code.
//Data.java

public void update(recNo, data, lockCookie) {

if (LockManager.isLocked(lockCookie)) {
throw new AppropriateException("The record is locked");
} else {
FileAccessManager.update(recNo, data);
}
}

Am I missing something or is this the way to go about it?

TIA
Niclas
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think it's a good design. If all the locking checks are done at the facade level you don't have to use LockManager in FileAccessManager or viceVersa. And through this you get a clear separation of concerns. If anyone thinks otherwise please reply.Thanks.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Niclas,

Your pseudo-code looks ok, but I guess the isLocked-method should take 2 arguments: recNo and lockCookie. And if the record is correctly locked the update should be executed (not throw an exception). Just my 2 cents.

btw I decided not to use the facade design pattern, just 1 Data class. So maybe I'm not the best person to give advice on this one

Good luck!
Kind regards,
Roel
 
Niclas ├ůstrand
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you both for your input! I thought I was missing something.

You are correct about the pseudo code Roel!

Niclas
 
You don't like waffles? Well, do you like this tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic