Method naming schemes for PEAR
| From: | Wolfram Kriesing | Date: | Fri, 19 Sep 2003 16:52:35 +0000 |
| Subject: | Method naming schemes for PEAR | ||
| Groups: | php.pear.qa | ||
| Request: | Send a blank email to pear-qa+get-200@lists.php.net to get a copy of this message | ||
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 clause
2.
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.
--
Wolfram
... opensource @ vision:produktion ...
http://opensource.visionp.de
... authentication system ....
http://sf.net/projects/auth