This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
when i'm writing my choices.txt I was wondering about the Data class: is it allowed to be abstract? or should it be a concrete class? instructions don't tell anything about it and for the record: data would implement all methods from sun's interface.
Of course i would have the abstract data class, and a concrete RoomData class for example. and i would use the RoomData class to delegate my service methods to. But if at sun they try to create an instance of Data, it would fail because it's abstract.
But you had a singleton Data, so your constructor of Data should be marked private and so they cannot create an instance of your Data class, so it seems it may be an abstract class. but i won't change it now anymore, to close to the finish line
abstract class and singleton class are 2 different things I think. Singleton must have a getInstance() method meaning you can create it or have an instance of it. Abstract class you can't even have an instance.
So what methods you have in your Data class if you also have a RoomData concrete class. If RoomData simply overrides Data class methods.... I don't see you need the extra RoomData class.
I was a bit unclear in my explanation. I meant if a program is used to test automatically your program and program contains coding like this
This program will not compile when Data is abstract class, but also not compile when you have a singleton, because Data.getInstance() should be invoked to get an instance.
The reason why i would make my data abstract and have a concrete RoomData has to do with making the Data a generic data access class which could be used to handle a file with rooms (through the RoomData, which has a speific check for eg. magic cookie and in future maybe also some other specific implementations of Data methods), but could also handle easily a file with customers (through a new concrete CustomerData class extending from Data). So it would become very easy to handle a similar file as the database file with hotel rooms