RE: [PEAR-QA] Method naming schemes for PEAR

From: Date: Fri, 19 Sep 2003 16:56:53 +0000
Subject: RE: [PEAR-QA] Method naming schemes for PEAR
References: 1  Groups: php.pear.qa 
Request: Send a blank email to pear-qa+get-202@lists.php.net to get a copy of this message
> From: Wolfram Kriesing [mailto:wolfram@visionp.de] > Sent: Friday, September 19, 2003 6:53 PM > 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. I don't think we need a regulation for this. Generally I think this should be up to the developer, but the names should of course balance verboseness with length. The number of parameters should also be watched out for. But I still don't think we need a hard rule for this. I your example the only one I find unobvious is orderBy() .. Regards, Lukas

« previous php.pear.qa (#202) next »