This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Open/Close file

 
Kevin Broderick
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
David Kachen
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • 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: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic