• 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

Bodgitt & Scarper 2.2.3 (Method overloading in Data class)

 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have written a new interface named DBReader that extends DBAccess interface. My new interface DBReader has defined few methods namely
  • connectDB();
  • deleteRecord(long recNo) throws RecordNotFoundException, SecurityException;
  • public void updateRecord(final long recNo, final String[] data) throws RecordNotFoundException, SecurityException;



  • and my Data class implements the DBReader interface and indirectly implements DBAccess . Now deleteRecord and updateRecord are overloaded methods in Data class and clients must invoke the new methods in order to delete or update the record. I have chosen this strategy to build locking functionality at server side and fulfil my Cookie requirement.

    my update method in Data class looks like the following

    similarly i have delete method also.

    Does my design look fine or Do I need to consider alternative way?

    thanks
    sat


     
    Sheriff
    Posts: 11604
    178
    Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi sat,

    I don't think creating an extra method just to group a call to lock, update and unlock is a good idea. I guess to book a room you make a call to your custom updateRecord? And I think you are missing one vital point here! My booking business logic goes as follows:
  • lock record
  • read record
  • check if room is already booked
  • if it is throw exception (don't allow 2 customers to book same room twice)
  • if it is not update record with customer id


  • So it seems you don't care about the check to see if a room is already booked, which would mean that 2-3-4 customers each can book that same room in the same hotel and be all present that evening at reception to claim they have a valid booking of their room

    Kind regards,
    Roel
     
    satishkumar janakiraman
    Ranch Hand
    Posts: 334
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi,
    I posted a sample code in my post. My operation flow is similar to yours. I just wanted to confirm whether an overloaded method is acceptable in Data class.


    sat
     
    Roel De Nijs
    Sheriff
    Posts: 11604
    178
    Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Sat,

    If your operation flow is similar to the one i suggested, your method name updateRecord is wrong! because checking if a room/contractor is still available is only a check you have to do with booking this room/contractor. Not when changing its size for example. So you have to rename it and you won't have an overloaded method.

    Another point against your approach, maybe even bigger than the 1st one: the data class (and sun's interface) are very general. you could read/write with that class also customers instead of rooms/contractors. So adding specific business logic for updating a contractor record to the general data class would be a poor design decision in my opinion

    Kind regards,
    Roel
     
    reply
      Bookmark Topic Watch Topic
    • New Topic