Re: Re: 1 class = 1 file?
| From: | David Coallier | Date: | Mon, 14 May 2007 01:09:00 +0000 |
| Subject: | Re: Re: 1 class = 1 file? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-46756@lists.php.net to get a copy of this message | ||
On 5/13/07, till <klimpong@gmail.com> wrote:
Hey, On 5/13/07, Mark Wiesemann <wiesemann@php.net> wrote: till wrote:I could easily see one exception in that 1 class per file rule though. Excepetions for instance.. <?php class MyNewException extends Exception { } class MyEvenNewerException extends MyNewException { } class OtherException extends Exception { } class PackageException extends PEAR_Exception { } ?> Don't get me wrong, but php itself (not talking about caching) is not *fast* at reading multiple includes. Doing one include where all the execptions are is (imo) a gain of speed after many includes (instead of doing require 'exceptionone.php' , require 'exceptiontwo.php', .... Having one file called for instance Exceptions or better yet Package_Execptions.php will be an easy gain of speed in general. Anyhoo, I would also be in favor of seeing something like this in the coding standards (which we are re-defining atm) -- David Coallier, Founder & Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18I thought I read this somewhere in the CS when I started working on my package. I also remember someone reminded me to put my Exception into a seperate file. Maybe that was even you, Mark? ;-)Right, it was me and it was the (non-existing) rule that I thought about.IMO and for clarity, it's one class per file. Having too many exceptions to the rule just weakens the "standard". And maybe - if it's not hidden somewhere already - this should be added to the docs.Well, the rule Lukas, David and (later also) I were talking about makes sense IMHO. Only internally used classes would be put together with other classes, public classes would still go into new files. Exception classes are public and used by user code, and would therefore also go into a new file. If you want to have a written rule somewhere in the docs, you should send an email to the PEAR Group. Adding a short paragraph to the docs would be easy, but there needs to be a decision about the rule first. Don't get me wrong. I was not trying to bust on you. :-) In general I am lazy and I tend to do all sorts of things when people don't look (= classes are only used internally) and because I know that I try to enforce rules on myself, my code and development which essentially improves whatever the outcome is, or whereever it is used. So instead of saying "this is internal", I am instead for one rule which is applied everywhere, as opposed a lot of if's and when's. Till -- PEAR Development Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php