Originally posted by Ulrich Heeger:
Now my question: Do you think I can justify a Class design, where it's necessary to first set explicitly properties before calling other methods?
I'm thinking about to throw an IllegalStateException within the getRecOffSet() and getRecLength()-method of my DataHelper-Class in case the properties haven't been set explicitly before.
Is this exaggerated caution?
Regards, George
SCJP, SCJD, SCWCD, SCBCD
Not at all, it seems like you would want to pass in the recOffset and recLength as parameters to the DataHelper class constructor. Then you know you will never have an instance of DataHelper for which the recOffset and recLength members are uninitialized.
Regards, George
SCJP, SCJD, SCWCD, SCBCD
What is the advantage to having the methods be static?
Originally posted by Ulrich Heeger:
Do you think it's ok to synchronize on a passed argument, I think yes, because the synchronization concerns the object itself and not the reference variable. Am I right?
Regards, George
SCJP, SCJD, SCWCD, SCBCD
Would it be possible for the DataHelper class to be a singleton? If so, would it be possible to move the raf to the DataHelper class? In that way it may be possible to have a static instance of the DataHelper class in the Data class and then database operations could synchronize on this static instance. Then you would have a single database file, a single raf to access the file, a single class to support accessing the raf (DataHelper). Each Data instance would synchronize its database operations on the static DataHelper instance in Data. This would essentially abstract the database file entirely out of the Data class and it would reside solely in the domain of the DataHelper.
Originally posted by Ulrich Heeger:
Sounds . But if I have a static instance of the DataHelper Class within my Data-Class, I don't need to make my DataHelper Class explicitly corresponding to the Singleton Pattern, am I right?
Regards, George
SCJP, SCJD, SCWCD, SCBCD
I have a knack for fixing things like this ... um ... sorry ... here is a consilitory tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|