If allowing getApplication() to be overridden adds bloat why is it allowable to 
override getSession() ?

Tom Burton

Sent from my HTC

----- Reply message -----
From: "Christoph Leiter" <[email protected]>
To: "[email protected]" <[email protected]>
Subject: Allow overriding of getApplication/getPage
Date: Wed, May 9, 2012 4:52 am




On 09.05.2012 14:24, Martijn Dashorst wrote:
> It adds bloat. Nobody (afaik) really likes these methods, as almost
> the same functionality can be achieved by using Application.get() or
> Session.get();

How is this bloat? I'm not proposing adding anything new, these methods 
are already there.

IMO getApplication() is much nicer than MyApplication.get() because I 
don't need to invoke static methods (at least on the surface).

> By opening up these methods for overriding, the contract is gone.
> Components can't rely on the fact that getApplication() does just
> that.

Well, if one wants to shoot themselves in the foot... The contract is 
usually the method signature plus javadoc. If one does something else 
they break this contract deliberately and have to live with the 
consequences.

> The use case you present for doing so is rather thin: there is nothing
> preventing you from creating a getMyApplication() method that has the
> correct type (as you already say you want to provide the correct type
> in your own base classes—just create your own method that has the
> correct type).

That's right, but now I really have bloat, namely getApplication/Page twice.


Christoph

Reply via email to