Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35714 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45929 invoked by uid 1010); 21 Feb 2008 23:44:03 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 45914 invoked from network); 21 Feb 2008 23:44:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Feb 2008 23:44:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@stefan-marr.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@stefan-marr.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain stefan-marr.de from 82.96.83.42 cause and error) X-PHP-List-Original-Sender: php@stefan-marr.de X-Host-Fingerprint: 82.96.83.42 serv6.servweb.de Linux 2.4/2.6 Received: from [82.96.83.42] ([82.96.83.42:52515] helo=serv6.servweb.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/5C-64513-3CC0EB74 for ; Thu, 21 Feb 2008 18:44:03 -0500 Received: from [192.168.0.25] (toolslave.net [85.88.12.247]) by serv6.servweb.de (Postfix) with ESMTP id 3D63F590015; Fri, 22 Feb 2008 00:45:32 +0100 (CET) Message-ID: <47BE0CC4.1090202@stefan-marr.de> Date: Fri, 22 Feb 2008 00:44:04 +0100 Reply-To: php@stefan-marr.de User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: "D. Dante Lorenso" Cc: Internals Mailing List References: <001c01c87264$3c01b4e0$b4051ea0$@de> <698DE66518E7CA45812BD18E807866CE014A8D9D@us-ex1.zend.net> <47BE0664.8060304@stefan-marr.de> <47BE0A09.6060702@lorenso.com> In-Reply-To: <47BE0A09.6060702@lorenso.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Redirected: By TestProxy Subject: Re: [PHP-DEV] Re: Traits for PHP ... Why can't every Class be a Trait? From: php@stefan-marr.de (Stefan Marr) Hi, D. Dante Lorenso schrieb: > All, > > I can imagine a case where you would want to box common functionality > into a trait and be able to use that trait as a class also. Will we end > up with a lot of classes like this?: > > class SomeClass { > use SomeTrait; > } > > What's wrong with making all 'Class'es be 'Trait's and the only thing > which makes a Trait a Trait is when you use it as such? > > class MyClass { > trait SomeClass; > } > > In other words, why mustn't a trait be instantiable? Why can't every > Class be a Trait? Well, the trait concept is not a silver bullet for all problems out there. What is wrong with inheritance or delegation for reusing complex behavior? Traits are for finer grained reuse in my eyes. The usage I've seen so far suggests typical traits are about 1 to 5 methods, but the average method count on a trait would be 1.88 or something like this (just a rule of thumb. from what I personally have looked at). Kind Regards Stefan