You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Willem van Asperen <Wi...@paconsulting.com> on 2006/05/26 21:44:02 UTC

subclass or bean?

Hello,

I have a set of pages that have very similar behavior. They have listeners like "handleTransition" and "startNewProcess". The first implementation I did was, obviously, to capture all these general functionality into XXX a subclass of BasePage and then sub class my page classes YYY from there.

Now I can DirectLink to these general listeners directly.

But -- is that the natural way to implement this? Should I not capture the general functionality into a bean that is "injected" into the page? But do I then need to manually wire the listener of the page to the bean's methods?

Is there a way to <page-description> for the XXX page, such that these are true for all descendents of it?

Thanks for your thoughts,

Regards,

Willem van Asperen

PA Consulting Group
Innovation. Responsiveness. Delivery.
Coltbaan 33
P.O. Box 1043
3430 BA Nieuwegein
The Netherlands
+31652015182
http://www.paconsulting.com/

DISCLAIMER:  This document should only be read by those persons to whom it is addressed and is not intended to be relied upon by any person without subsequent written confirmation of its contents.  PA Consulting Group disclaims all responsibility and accepts no liability (including in negligence) for the consequences of any person acting, or refraining from acting, on such information prior to the receipt by those persons of subsequent written confirmation.  If you have received this e-mail message in error, please notify us immediately by telephone on +31302829600.  Please also destroy and delete the message from your computer.  Any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message is strictly prohibited.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: subclass or bean?

Posted by Jesse Kuhnert <jk...@gmail.com>.
It depends on exactly what kind of functionality you are working with in
these listeners, but I would probably do something similar to:

-) If you do have functionality that's not related to the web stuff at all
make it a bean that is managed via hivemind, ie make it a service that you
inject. http://jakarta.apache.org/hivemind/hivemind/BuilderFactory.html

-) Try to avoid subclassing whenever possible. Sometimes it's needed, but
often times it usually means there might be a better way.

In your case I would do what comes naturally in tapestry when you have
common functionality like this, create components. (they can have listeners
and do pretty much anything that a page can do ) Wrap all of it in a Border
component that itself just wraps these components.

Most Border components (you can find ample examples in the tapestry example
apps ) wrap Shell Body (custom common fucntionality components, like
navigation/etc..) @RenderBody to allow your page to have its content
written, and finally a common footer.

On 5/26/06, Willem van Asperen <Wi...@paconsulting.com> wrote:
>
> Hello,
>
> I have a set of pages that have very similar behavior. They have listeners
> like "handleTransition" and "startNewProcess". The first implementation I
> did was, obviously, to capture all these general functionality into XXX a
> subclass of BasePage and then sub class my page classes YYY from there.
>
> Now I can DirectLink to these general listeners directly.
>
> But -- is that the natural way to implement this? Should I not capture the
> general functionality into a bean that is "injected" into the page? But do I
> then need to manually wire the listener of the page to the bean's methods?
>
> Is there a way to <page-description> for the XXX page, such that these are
> true for all descendents of it?
>
> Thanks for your thoughts,
>
> Regards,
>
> Willem van Asperen
>
> PA Consulting Group
> Innovation. Responsiveness. Delivery.
> Coltbaan 33
> P.O. Box 1043
> 3430 BA Nieuwegein
> The Netherlands
> +31652015182
> http://www.paconsulting.com/
>
> DISCLAIMER:  This document should only be read by those persons to whom it
> is addressed and is not intended to be relied upon by any person without
> subsequent written confirmation of its contents.  PA Consulting Group
> disclaims all responsibility and accepts no liability (including in
> negligence) for the consequences of any person acting, or refraining from
> acting, on such information prior to the receipt by those persons of
> subsequent written confirmation.  If you have received this e-mail message
> in error, please notify us immediately by telephone on +31302829600.  Please
> also destroy and delete the message from your computer.  Any form of
> reproduction, dissemination, copying, disclosure, modification, distribution
> and/or publication of this e-mail message is strictly prohibited.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tacos/Tapestry, team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind.

Re: subclass or bean?

Posted by Stephane Decleire <sd...@cariboo-networks.com>.
I would vote for subclassing :
1. It's the core of OOP to share common pieces of code in a parent class.
2. A bean is not a library. A bean should be seen as an independant 
entity which can have a life by itself ...
IMHO ;-)

Willem van Asperen wrote:

>Hello,
>
>I have a set of pages that have very similar behavior. They have listeners like "handleTransition" and "startNewProcess". The first implementation I did was, obviously, to capture all these general functionality into XXX a subclass of BasePage and then sub class my page classes YYY from there.
>
>Now I can DirectLink to these general listeners directly.
>
>But -- is that the natural way to implement this? Should I not capture the general functionality into a bean that is "injected" into the page? But do I then need to manually wire the listener of the page to the bean's methods?
>
>Is there a way to <page-description> for the XXX page, such that these are true for all descendents of it?
>
>Thanks for your thoughts,
>
>Regards,
>
>Willem van Asperen
>
>PA Consulting Group
>Innovation. Responsiveness. Delivery.
>Coltbaan 33
>P.O. Box 1043
>3430 BA Nieuwegein
>The Netherlands
>+31652015182
>http://www.paconsulting.com/
>
>DISCLAIMER:  This document should only be read by those persons to whom it is addressed and is not intended to be relied upon by any person without subsequent written confirmation of its contents.  PA Consulting Group disclaims all responsibility and accepts no liability (including in negligence) for the consequences of any person acting, or refraining from acting, on such information prior to the receipt by those persons of subsequent written confirmation.  If you have received this e-mail message in error, please notify us immediately by telephone on +31302829600.  Please also destroy and delete the message from your computer.  Any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message is strictly prohibited.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>For additional commands, e-mail: users-help@tapestry.apache.org
>
>  
>

-- 
Stéphane Decleire

05 56 57 99 20
06 63 78 69 06