• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

encapsulation(lock,unlock)

 
Peter Kovgan
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Bodgitt and Scarper demands lock(int),unlock(int) methods implementation
in Data.class,so these methods are PUBLIC in Data.class, but what I should do to hide these methods from clients?
For example, I want to book record: "doBOOK(int)" and from this method call: lock, book,unlock.
I want to hide these subfunctions from client.
Please help.
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter,
This thread discusses that subject in detail.
what I should do to hide these methods from clients?

The good news are that in java, hiding is the default situation and showing is the exception.
All the public stuff in your suncertify.db package will be hidden to any class outside the db package if that class doesn't explicitely import suncertify.db. It looks obvious, hence I think I replied your question.
Let's start from the "Book" button. From its ActionListener, you won't probably call your doBOOK(int) method, but some bookButtonClicked() method in some Controller. The class where your doBOOK(int) resides is hidden from (I'd better say "not shown to) the View.
Your Controller knows where to find the int parameter needed, gets it and calls doBOOK(int) in some other class.
Now, some class somewhere implementing the doBOOK(int) method must be able to deal with the low-level data stuff and here comes the choice :
  • Or that class is implemented client-side and will call remote low-level DBAccess methods
  • Or it is implemented server-side, meaning that your client-side doBOOK(int) method will call the remote doBOOK(int) method


  • Best,
    Phil.
     
    Peter Kovgan
    Ranch Hand
    Posts: 84
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you, Philippe!
    I posted my reply at this endless thread.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic