[fpc-devel] Parameters must match exactly?

Florian Klaempfl florian at freepascal.org
Tue May 18 10:12:19 CEST 2010


Graeme Geldenhuys schrieb:
> Florian Klaempfl het geskryf:
>> http://en.wikipedia.org/wiki/Factory_method_pattern
>>> Sorry for the sarcasm, 
>> Sarcasm? For sarcasm, you need to have a clue.
> 
> No need to be rude.
> 
> Maybe I can chip in, because design patterns are right up my alley. Maybe
> you forgot, but a design pattern is not a code template! It normally
> describes *one* possible way of implementing that pattern - many other ways
> can exist. 

Nobody doubts this, this is also why I wrote "normally" in my initial
post. Nevertheless I didn't see a single valid reason yet why
implementing the factory method pattern cannot be done using a function:
- it is one of the basic programming principles: if a result is returned
by a subroutine, use a function
- it makes things more intuitive to read because it looks like a constructor

If you really want to use a var-parameter, insert an explicit typecast
then everybody knows: "this code is dangerous, we have to keep an eye on
it".



More information about the fpc-devel mailing list