Re: Method naming schemes for PEAR
| From: | Greg Beaver | Date: | Fri, 19 Sep 2003 16:58:32 +0000 |
| Subject: | Re: Method naming schemes for PEAR | ||
| References: | 1 | Groups: | php.pear.qa |
| Request: | Send a blank email to pear-qa+get-203@lists.php.net to get a copy of this message | ||
Hi Wolfram,
#2 is indeed clever :). I always find my clever code is the hardest crap to debug, unfortunately, but this may not be true of #2.
I'm not sure it is possible to mandate method naming - the state of the language is changing rapidly enough, it may serve to simply limit future innovation. Perhaps these could simply be recommended practices that have been tried and tested? Then they can be changed if some incredible new feature/coding practice comes along.
The manual's CS is very verbose, I never remember all of it, and certainly never reference it when writing my code, I just check out other projects to see how they did it. Perhaps that could be the focus of the CS discussion: documenting CS succinctly and clearly? Your/Alan's ideas for method naming could be a part of the naming section as suggestions for good practice.
Greg
Wolfram Kriesing wrote:
i had a discussion with Alan some days ago about naming of methods. Now i thought i might forward this to the list. What is the prefered way of naming methods, here are two possible ways, which one is encouraged by PEAR, or is there one that PEAR will define as CS? Just fyi the methods are working on the "OrderBy" part of a query, and are only examples! 1.getOrderBy() get the current orderBy-clause addOrderBy(x,y) add another orderBy-clause resetOrderBy() reset the order clause2.orderBy() does the same as getOrderBy() orderBy(x,y) does the same as addOrderBy(x,y) orderBy(null) does the same as resetOrderBy()The first one is very readable, esp inside a lot of code. The second one is clever, and really has advantages regarding code size: you only have one method, the code is shorter and faster! But the second one might be confusing when other methods in the class dont work this way. Should something like this be decided for PEAR? I think so. And btw. i am in favour or 1, simply because the method name clearly states what this method does.