> Andrei Zmievski wrote:
> > On Jan 9, 2006, at 4:09 AM, Aidan Lister wrote:
> > 
> >> As useful functions tend to increase in complexity over 
> time, often 
> >> so does the number of parameters.
> >>
> >> It soon gets to the point where function calls look like:
> >> foo(true, false, false, false, false, true) The rest of the 
> >> parameters being required to be supplied, with their 
> default value, 
> >> when the user is only interested in changing the last option.
> >>
> > 
> > If you get to the point where your function has a dozen 
> parameters, I 
> > would suggest re-thinking the purpose and design of such a 
> function, 
> > because you are likely trying to make it do too much.
> > 
> > -Andrei
> 
> In a simple highlighting function I wrote (which at 16k hits 
> is probably 
> considered useful) I needed most of the following parameters:
> 
> $text
> $needle
> $strip_links
> $case_sensitive
> $whole_word_only
> $simple_text_only
> $highlight_pattern
> $return_or_print
> $use_xhtml
> $tooltips_or_divs
> 
> I imagine any function dealing with html may use a 
> significant portion 
> of these. Obviously some of these are for effect, but I think 
> my point 
> is clear enough.

I think that's a poor example. I see a highlighting problem split into multiple 
classes. 
One that generates a SAX stream from html, another class or two modifies SAX 
event stream, one removing links, and another injecting
highlighting elements, and another pair of classes to reassemble the SAX event 
stream back into a string, one doing HTML, the other
XHTML.

If you have too many parameters that you want to start omitting parameters when 
calling a function, its probably time to refactor.

Jared
  

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to