You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jim O'Callaghan <ji...@peritussolutions.com> on 2010/07/19 16:24:20 UTC

Best practise for bloated utility methods location

I have a 'base' Page class that has behaviour used throughout a large
section of application pages, and is extended by them.  It's starting to get
a bit bloated with utility methods.  Is it better practise / more efficient
to extract these utility methods from the base page class and put them in a
helper service, that can be injected into pages, or is there any advantage /
disadvantage to either approach?  Any first-hand experience of pros / cons
of each approach?  Thanks.

 

Regards,

Jim.


Re: Best practise for bloated utility methods location

Posted by Pablo dos Reis <pa...@gmail.com>.
Hi Jim,

Where I work the apporoach is like this:
"Base Pages" are used for prevent some duplicates methods that returns
models, enconder or same actions to remove or include.
Services are used to actions in the business.

But this approach not consider efficiency and it's only a pattern.



2010/7/19 Jim O'Callaghan <ji...@peritussolutions.com>

> I have a 'base' Page class that has behaviour used throughout a large
> section of application pages, and is extended by them.  It's starting to
> get
> a bit bloated with utility methods.  Is it better practise / more efficient
> to extract these utility methods from the base page class and put them in a
> helper service, that can be injected into pages, or is there any advantage
> /
> disadvantage to either approach?  Any first-hand experience of pros / cons
> of each approach?  Thanks.
>
>
>
> Regards,
>
> Jim.
>
>


-- 
Pablo Henrique dos Reis

RE: Best practise for bloated utility methods location

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Pablo, Thiago,

Thanks for the responses.  Thiago, the idea of the utility methods also being available outside a page is a good enough reason for me to move them into a service.  Thanks for the pointer.

Regards,
Jim.

-----Original Message-----
From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Sent: 19 July 2010 15:59
To: Tapestry users
Subject: Re: Best practise for bloated utility methods location

On Mon, 19 Jul 2010 11:24:20 -0300, Jim O'Callaghan  
<ji...@peritussolutions.com> wrote:

> I have a 'base' Page class that has behaviour used throughout a large
> section of application pages, and is extended by them.  It's starting to  
> get a bit bloated with utility methods.  Is it better practise / more  
> efficient to extract these utility methods from the base page class and  
> put them in a helper service, that can be injected into pages, or is  
> there any advantage / disadvantage to either approach?  Any first-hand  
> experience of pros / cons of each approach?  Thanks.

I think the approach of coding utility methods in services is the best  
one. Services are more flexible than pages, and methods in services can be  
used outside pages as well.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informa��o Ltda.
http://www.arsmachina.com.br

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


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


Re: Best practise for bloated utility methods location

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 19 Jul 2010 11:24:20 -0300, Jim O'Callaghan  
<ji...@peritussolutions.com> wrote:

> I have a 'base' Page class that has behaviour used throughout a large
> section of application pages, and is extended by them.  It's starting to  
> get a bit bloated with utility methods.  Is it better practise / more  
> efficient to extract these utility methods from the base page class and  
> put them in a helper service, that can be injected into pages, or is  
> there any advantage / disadvantage to either approach?  Any first-hand  
> experience of pros / cons of each approach?  Thanks.

I think the approach of coding utility methods in services is the best  
one. Services are more flexible than pages, and methods in services can be  
used outside pages as well.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Best practise for bloated utility methods location

Posted by Howard Lewis Ship <hl...@gmail.com>.
I prefer to avoid base classes so I package such utility methods into
one or more services and just freely inject those services into my
pages and/or components.

On Mon, Jul 19, 2010 at 7:24 AM, Jim O'Callaghan
<ji...@peritussolutions.com> wrote:
> I have a 'base' Page class that has behaviour used throughout a large
> section of application pages, and is extended by them.  It's starting to get
> a bit bloated with utility methods.  Is it better practise / more efficient
> to extract these utility methods from the base page class and put them in a
> helper service, that can be injected into pages, or is there any advantage /
> disadvantage to either approach?  Any first-hand experience of pros / cons
> of each approach?  Thanks.
>
>
>
> Regards,
>
> Jim.
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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