Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Should Data class be a singleton and have all method synchronized?

 
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I read some of the old posts in the forum.
Someone suggested making Data class a singleton and synchronized all its methods.
In the requirement, it does not say this.

So, can I use Monkhouse book's approach to make Data class a facade?

In Monkhouse book , the DvdDatabase class is a facade and it is not a singleton to my understanding. In DvdDatabase class, there are two static objects of ReservationManager and DvdFileAccess. Only one instance of each of them is created and all methods in ReservationManagers and DvdFileAccess are made to be thread safe (by synchronizing blocks of codes or using lock).

 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's all up to you!
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my assignement, the Data class is not a singleton. I have justified it by explaining that my Data class could be reused to manage another kind of records in a second data file. Moreover, the Data class methods are not synchronized. I simply used synchronized blocks within the methods only when it was necessary to make the Data class thread safe. My choices are inspired from what I read in the Monkhouse book.

However, I don't know if I'll get full credit : I have submitted my assignments two days ago and I'll sit for the essay Thursday ;)

I also think that the different options are possible, we just need do justify it in our choices.txt file.
 
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
  • Quote
  • Report post to moderator

Guillaume Drouet wrote:I'll sit for the essay Thursday ;)


Good luck, champion! I'm convinced you'll pass with flying colours
 
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic