Originally posted by Pho Tek:
I read somewhere that you should let your domain model dictate the database model; not the other way round.
Pho
Originally posted by Ilja Preuss:
Interesting - could you elaborate on this? Where did the problems emerge?
I hope you didn't want to imply that your object model should be driven by database design
Originally posted by Andron Dre:
Hi
But they never said about scalability and pooling.
So by accessing it without ejb, we are loosing all scalability.
And often harder to maintain, because of less encapsulation.
Originally posted by Ilja Preuss:
That seems to be the wrong question to me. The more interesting question is: When do you see all static classes, when singletons?
Originally posted by Alan Shalloway:
Actually, the essence of a singleton is controlling the construction of the object. protected will work just fine for that so inheritance will work.
To enforce the nature of a singleton class, you must code the class in a way that prevents other classes from directly creating instances of the class. The way to accomplish this is to declare all of the class' constructors private.
There is one other case I can think of, using a singleton can potentially control the order of when the object is instantiated better. With static methods, the static members will be instantiated the first time the class is referred to. This may be a reference to some const in the class. In the singleton pattern, it won't be instantiated until the getinstance is called.
Originally posted by Ilja Preuss:
The point of the singleton pattern ist to hide the detail that there is only one instance.
In fact, getInstance() could give you a new instance each call, or alternate between two instances or...
Also, using the singleton pattern you can still use polymorphism, that is getInstance() could give you an instance of an other (sub-)class (depending on some configuration, for example).
Therefore, an all-static class is not a substitute for a singleton![/B]
Originally posted by Wilfried LAURENT:
It depends on what you want to achieve.
With the singleton implementation, you can hide the real implementation of your service. The client only knows the contract (API) but does not know about the implementation. This is easily configurable with a bridge or a property file.
You can not do that with a 'static method' implementation.
W.