SCSA, OCA, SCJP 5.0, SCJD, CCDH, CCAH http://www.linkedin.com/in/carlosamorillo
Roel De Nijs wrote:In my humble opinion: yes, they should. And the reason is quiet obvious: best practice would be to program against an interface, so you can easily change the implementation with another implementation without braking your code. And if you don't add this methods to your interface then you can't invoke these methods. And if it's not necessary they are called from somewhere else, methods should of course not be public.
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
SCSA, OCA, SCJP 5.0, SCJD, CCDH, CCAH http://www.linkedin.com/in/carlosamorillo
SCSA, OCA, SCJP 5.0, SCJD, CCDH, CCAH http://www.linkedin.com/in/carlosamorillo
Also, if you make your Data class to read dynamically all the values from the schema in the database file
such as numberOfFields without hardwiring and declaring a lot of constants, I was thinking about having
a method getNumberOfFields() declared as public static that could be called by my Room class that has conversion methods
public static String[] toStringArray(Room room) and public static Room toRoom(String[] record).
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
SCSA, OCA, SCJP 5.0, SCJD, CCDH, CCAH http://www.linkedin.com/in/carlosamorillo
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
SCSA, OCA, SCJP 5.0, SCJD, CCDH, CCAH http://www.linkedin.com/in/carlosamorillo
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
Carlos Morillo wrote:I guess in your Room class you just solved this by declaring a static private final NUMBER_OF_FIELDS= 7;
because I just created an anonymous array.
SCSA, OCA, SCJP 5.0, SCJD, CCDH, CCAH http://www.linkedin.com/in/carlosamorillo
That's true, but that happens only in the create method of the Data class (and in this class you have knowledge about the database schema, so no constant required). In the method to convert my room object to a String[] I just have this code:Carlos Morillo wrote:Well at some point you have to instantiate the String[] and specify the size with 7 elements.
The static getInstance method can't be in the interface of course. If you use a dao factory (like I did) this is not really a problem
SCSA, OCA, SCJP 5.0, SCJD, CCDH, CCAH http://www.linkedin.com/in/carlosamorillo
That's true, but I didn't do a check. Is one of the very few methods which parameters are not validated.I still think if you are going to validate the String[] length in a method like public static Room toRoom(String[] record)
you would still need a constant.
I don't know exactly what you mean, but I found this link very helpful.Is it necessary to define an interface to be implemented by the DAO Factory object?
Don't get me started about those stupid light bulbs. |