[fpc-pascal] Implementing Factory Method with Pascal
luciano de souza
luchyanus at gmail.com
Fri Nov 27 22:44:16 CET 2015
Yes, it works. But in this case, I don't understand the sense of the pattern.
If I need to do "TAnimalFactory.create(atDog) as Tdog", perhaps, it
would be better not to use a factory, doing simply "TDog.create".
I don't understand if I have implemented the pattern wrongly or if
this pattern, becose of the strong typing of the language, does not
make sense in Pascal.
2015-11-27 19:30 GMT-02:00, Mattias Gaertner <nc-gaertnma at netcologne.de>:
>
> One solution:
>
> var
> animal: TDog;
> BEGIN
> animal := TAnimalFactory.create(atDog) as TDog;
> try
> animal.bark;
> finally
> animal.free;
> end;
> END.
>
>
> Mattias
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
--
Luciano de Souza
More information about the fpc-pascal
mailing list