• 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

Open/Close file

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

Its being a while since I've had to trouble some of ye. Indeed I'm down to the last 15% left to do in the assignment and so I took a break because I'm starting to get tired of it . Right, I'll just get to the point.

I've got two methods Open and Close. Open as you can guess, opens the data file and populates data's hashmap and close will take data's hashmap and write back out to the datafile. Open is implemented and it works fine but I'm not sure of the design approach. My question then is this:

1) Should I create a seperate file class implementing Open/Close within the package db where the data class can access and populate its hashmap by the method Open return value and pass its hashmap in close as a parameter.

2) Should I just leave these two methods within the class data making them private members.

3)or is there a better design approach to this.

Thanks in advance
Kevin
 
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 Kevin,

My Data class just has the open and close methods as private members (methods) in the Data class itself. Not making it more complex by adding another class, just keeping it simple. I even don't have a seperate locking manager, the Data class also takes care of the locking

Kind regards,
Roel
 
Kevin Broderick
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roel,

Thank you for your super fast reply and I'm glad to read open and close stays within the data class.

Cheers
Kevin
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.

Roel De Nijs wrote:
My Data class just has the open and close methods as private members (methods) in the Data class itself.



You are open and close the data file in each operation? if I understood you correctly..

Best regards..
 
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

David Kachen wrote:You are open and close the data file in each operation? if I understood you correctly.


No, you don't. I used a record cache, so I only need access to the file at startup and shutdown.
 
reply
    Bookmark Topic Watch Topic
  • New Topic