• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data layer question

 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hallo,

I have some questions about the Data Acccess layer.

My DBMain interface encapsulate two different behavior/responsabilities, the data manipulation (read, update, delete, find methods) and the locking (lock, unlock, isLock methods).

For this I try to isolate each specific behavior in to a separate interfaces
DataAccess and LockingManager.

The DataAccess(implementation) is responsible for the data manipulation and
the LockingManager(implementation) for the locking actions.

The Data(which implements the DBMain) class compose the both behaviors and its acts like a facade(all the calls here are delegated to the LockinManager or to the DataAccess).

In my specification I found :
"Your data access class must be called Data.java "

What this supose to means ?
If I must implement my data acces mechanism together with the locking mechanism in the same class(Data) ?

Or I can let the two mechanisms separated and combine them in the Data class?


ThanX,


Mihai
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All access to your data must go through the Data class. That means that regardless of how it works in the underlying structure, a call to Data.update(), or Data.unlock(), or Data.lock(), etc... must preform as specified by the interface.

If I am understanding you correctly, your Data.update() method calls DataAccess.update(), and your Data.lock() calls LockingManager.lock(), etc... right? I see no problem with doing it this way, as you are still fulfilling the requirements of the DBMain contract.

Personally, I implemented both the manipulation and locking mechanisms in the same class, but I see the advantages to your solution.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul

Yes you are right.All the Data methods call methods on DataAccess and on LockingManager.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mihai,

i did it the same way and think this aproach is o.k.!
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hallo Oliver,

I am happy to hear that are more people in the same "boat" with me.
One more question, my data acccess class throws more exception that the facade/DBMain docs specify(DBMain throws only RecordNotFound and DuplicateKey).
By example if somethig happen with the data base file during running, or a part of the file is corrupted.Let's say a previous application has a bug and from record n it adds an extra field per record - your data scheme works onyl until the n-1 recod.For all this special cases I throw an (or some) exception.

On my Data class I catch them and thow only RecordNotFound(which warps the real exceptions).

How is(was) on you ?


Regards,


Mihai
[ June 08, 2005: Message edited by: Mihai Radulescu ]
 
Would you like to try a free sample? Today we are featuring tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic