If there is no "must" requirement about the constructor you are free to do what you want In fact I applied the singleton design pattern on my Data class, so my default constructor is marked private and i passed
Maybe they have for automatic testing a program where they just have to add 1 line: creating the Data instance (according to your javadoc) and let it run...
I am using a singleton as well. I pass in a database path into getInstance method and actually have an overloaded version without params. I know this is a terrible design but I throw a custom exception when it isn't used properly. Is there a way I didn't think of to get around this. I don't like the idea of having a setter for the database path. How did you get the database path to Data? by the way I have been reading a lot of your posts... You are a very adept at teaching, when you help people solve their problems you do it in a way that is understandable and you are very humble (in my opinion a must for any teacher) which helps people build their confidence. I was very insecure when I began the project, only a week later, I am almost cocky! Just wanted to say thanks man .
My Data class has just 1 getInstance method with 0 parameters, so you can get around this (and I didn't use a setter too). What did I do? I created my own interface which extends the given interface and I added 2 methods to this new interface: 1 for initializing (with a parameter containing the database path) and another one for "destroying" (releasing any resources, writing cache back to file,...)
Andy Gertjejansen wrote:I have been reading a lot of your posts... You are a very adept at teaching, when you help people solve their problems you do it in a way that is understandable and you are very humble (in my opinion a must for any teacher) which helps people build their confidence. I was very insecure when I began the project, only a week later, I am almost cocky!
Thanks for these kind words, Andy. Some appreciation now and then is always nice to hear Concerning the teaching: before I started my Applied Computer Sciences study, I was trying to become a secondary teacher, because being a math teacher was my little boy's dream. After 1.5 years I decided it wasn't my cup of tea and switched to the IT training, a very wise decision in the end
Sorry for bothering you so much just to make sure. You had an interface (lets call it Foo) that extends the DB interface and then just implemented Foo and that was ok with the assessors? I imagine it would be because you are still implementing DB by implementing an interface that extends to it but just thought I would ask to make sure. I also don't mean to straight up copy your design but it is such a good idea unfortunately I cannot resist!
Did you already have read my story about SCJD? A link is provided in my signature. It contains a lot of information about how I tackled/handled the assignment and also an overview of the high-level decisions I took. First item under "Data class" is:
Roel De Nijs wrote:created my own interface (extending the sun interface)
And as you can see I passed (even with a maximum score ), so it's certainly fine for the accessors.