What to use instead of parent()?

45 views
Skip to first unread message

Tony Xiao

unread,
Oct 17, 2010, 6:17:42 PM10/17/10
to play-framework
The play Controller has a parent() method which is really useful. But
now it's deprecated. What should we use instead of it?

http://www.playframework.org/@api/play/mvc/Controller.html

Guillaume Bort

unread,
Oct 18, 2010, 7:10:58 AM10/18/10
to play-fr...@googlegroups.com
With the current implementation of the Controller layer in Play,
controllers inheritance is a bad practice.

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

CP

unread,
Oct 29, 2010, 6:55:27 AM10/29/10
to play-framework
Hi,

Although I am still not quite understand why controllers inheritance
is not a good practice. But I've found the way to get rid of those
deprecated warning.

original method:

public static void show() {
parent();
}

updated method:

public static void list() {
CURD.list();
}

Hope it helps to kill your warnings.

On Oct 18, 7:10 pm, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> With the current implementation of the Controller layer in Play,
> controllers inheritance is a bad practice.
>
> On Mon, Oct 18, 2010 at 12:17 AM, Tony Xiao <tonyx...@gmail.com> wrote:
> > The play Controller has a parent() method which is really useful. But
> > now it's deprecated. What should we use instead of it?
>
> >http://www.playframework.org/@api/play/mvc/Controller.html
>
> > --
> > You received this message because you are subscribed to the Google Groups "play-framework" group.
> > To post to this group, send email to play-fr...@googlegroups.com.
> > To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/play-framework?hl=en.
>
> --
> Guillaume Bort,http://guillaume.bort.fr
>
> For anything work-related, use g...@zenexity.fr; for everything else,
> write guillaume.b...@gmail.com

Michael Boyd

unread,
Oct 29, 2010, 7:19:19 AM10/29/10
to play-fr...@googlegroups.com
I don't understand Guillaume's problem with controller inheritance. I
have about 10 sites in a single code base and they all extend from the
same controller (BaseController). I have no problems with it, and it's
even a benefit.


--
-- Michael Boyd

Guillaume Bort

unread,
Oct 29, 2010, 7:50:20 AM10/29/10
to play-fr...@googlegroups.com
Because inheritance means polymorphism. And with polymorphism routing
and reverse-routing is way more complicated. In Play action methods
are static because it allow to express explicitly the exact method to
call.

You can still inherit another controller as long as you don't try to
override any existing action method.

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,

write guillau...@gmail.com

Julien Tournay

unread,
Oct 29, 2010, 7:51:17 AM10/29/10
to play-fr...@googlegroups.com
Well, I'd said that the only usage of controller inheritance (apart extending the Controller class) is to share code between classes. Using inheritance for that is an anti-pattern in general (not only in Play, but in every OO languages).

jto.

On Fri, Oct 29, 2010 at 1:19 PM, Michael Boyd <mic.t...@gmail.com> wrote:



--
Real Programmers don't need comments-- the code is obvious.

Guillaume Bort

unread,
Oct 29, 2010, 8:05:57 AM10/29/10
to play-fr...@googlegroups.com
> Well, I'd said that the only usage of controller inheritance (apart
> extending the Controller class) is to share code between classes.
> Using inheritance for that is an anti-pattern in general (not only in Play,
> but in every OO languages).

Yes especially that the controller layer is not object oriented in Play.

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,

write guillau...@gmail.com

Reply all
Reply to author
Forward
0 new messages