This is a discussion on Re: What is/is not considered to be good OO programming within the PHP Language forums, part of the PHP Programming Forums category; Jochen Daum <jochen.daum@cans.co.nz> wrote in message news:<c6d5jv4v8gm18j1kfu1thkom2erfq9itse@4ax.com>. .. > Hi ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Jochen Daum <jochen.daum@cans.co.nz> wrote in message news:<c6d5jv4v8gm18j1kfu1thkom2erfq9itse@4ax.com>. ..
> Hi Tony! <snip> > The others wrote everything I could write. > > My database class also supports a limit statement, I especially wrote > it, because its such a hassle to limit with MSSQL. > > IMO, doesn't matter, if irt is parameter or class variable. I prefer > parameter, because I don't like: > > $arith->x = 1; > $arith->y = 2; > $m = arith->multiply(); > > I rather like: > > $m = arith->multiply(1,2); > > HTH, Jochen > The reason that I use separate variables instead of parameters on the getData() method is that the number of possible parameters is quite large and most of them are optional. So instead of having a long list of parameters on the getData() method I find it easier to use a separate set...() method whenever I DO have a value that I want to be used. That is my personal preference. If I have a method which has a small number of parameters then I would stick to supplying them on the method call as you suggest. The difference lies in the number of parameters and how many of them are optional. Tony Marston http://www.tonymarston.net/ |
|
|||
|
Hi Andre!
On Tue, 12 Aug 2003 17:13:09 +0000, André Nęss <andrena.spamreallysucks@ifi.uio.no> wrote: >Tony Marston: > >>> Keyword arguments are very practical in this type of problem, but they >>> are unfortunately not supported by PHP. A common workaround is to use >>> assoc arrays to pass the parameters, something that had felt a lot >>> cleaner had PHP supported a more practical array notation than >>> array('a'=>1, 'b'=>2, 'c'=>3). >>> >>> My favorite: >>> ['a': 1, 'b': 2, 'c': 3] >>> >>> André Nęss >> >> I prefer to use the features that the language does allow and not >> waste my time in dreaming up features that it does not. > >My main goal was to point out that assoc-arrays as parameters sometimes can >be an acceptable trick and it is supported by PHP, so that's not something >I'm dreaming up. I think its more than a good trick. Jochen -- Jochen Daum - CANS Ltd. PHP DB Edit Toolkit -- PHP scripts for building database editing interfaces. http://sourceforge.net/projects/phpdbedittk/ |