Jim Hoglund wrote:Billy : Let's construct a scenario to illustrate how polymorphism is really used. Consider a
hypothetical TV remote control.
Let's say that interface BasicControl declares methods: on(), off(), volume() and channel() and
that class RemoteV1 implements this interface; nothing extra, just the declared functions. The
methods available on 'x' would be the same for either "BasicControl x = new RemoteV1()" or
"RemoteV1 x = new RemoteV1()". But since we've been told to "design to the interface", we
deploy our program with the first "interface" definition.
Now it's time for an upgrade, adding methods mute() and sleepTimer(). Let's declare the new
methods in interface BetterControl which extends BasicControl. The new implementing class will
be RemoteV2 which extends RemoteV1. Also, let's say that an improved channel() method has
been developed and will be included in RemoteV2.
So what do we have? In writing RemoteV2 we didn't disturb the validated RemoteV1 methods
as they were inherited. The new mute() and sleepTimer() methods were coded and validated.
We decided, however, to include an overriding channel() method with better performance.
Older remotes can be upgraded by replacing RemoteV1 references with RemoteV2 and no other
changes. This works because "BasicControl x = new RemoteV2()" will work fine; even better
because RemoteV2 provides an improved channel() method (override). New remotes will need
"BetterControl x = new RemoteV2()" to access the new methods. Plus other program changes to
take advantage of the new behaviors.
Jim ... ...
David Newton wrote:What magic numbers?
XML vs annotations really depends on your needs. Personally, I still use XML for some things--it keeps classes leaner, more clear, and more exportable into other environments. For some things, annotations are awesome, though.
Tim Holloway wrote:If free is the limiting factor, PostgreSQL might be the better choice. MySQL added stored procedures and related refinements relatively recently (MySQL 5). User-defined Functions (UDFs) have to be coded in C. In comparison, PostgreSQL has supported triggers, stored procedures and user-defined functions for a long time now, and alows a broader selection of languages to be used.
Of course, given a UDF that does an OS exec() call, you can do just about anything.
Mark Spritzler wrote:You need to inject the EntityManagerFactory, then in your methods call the getEntityManager() of the factory. This is needed because you can't create an EntityManager up front, with a Connection, and have your Repository hold on to it forever. This is bad resource holding. So it isn't possible for you to inject an EntityManager.
I hope that helps and makes sense. It is an extremely correct and best implementation to not allow you to inject an EntityManager.
Good Luck
Mark
Sean Clark wrote:Hey,
Whilst this isn't a direct answer I know that Spring uses cookies to save this kind of information and can use it to store information about the Locale and Theme settings which (I think) can be used between session. So maybe using cookies is an option? Here is a link with some basic info on cookies
Sean
David Newton wrote:http://struts.apache.org/2.1.8/docs/why-cant-i-use-jstl-style-el-expressions-in-struts-tags.html
Or use <s:set>. Either I or someonebody else wrote a thing about accessing JSP tag attributes, but I can't find it at the moment. In this case, if it's a string, it's just as easy this way.
David Newton wrote:No, that's the way Java works: it's like crack for people that like to type. For things like this I usually just create another base class if it's functionality used all over the place. Unfortunately, Java provides no trivial mechanism for sharing implementation.