Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Marcos Douglas
On Sat, Nov 28, 2015 at 9:11 AM, Juha Manninen wrote: > On Sat, Nov 28, 2015 at 1:48 AM, Marcos Douglas wrote: >> Another tip: Factories resolve some problems but there is a cost. The >> factory will creates your instance (object) but it know only one

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Graeme Geldenhuys
Hi Marcos, On 2015-11-27 23:48, Marcos Douglas wrote: > Why do you have a factory to create different types of animals > (classes)? Doesn't make sense. Maybe in Luciano's simple example a factory is not the best use case, but the Simple Factory design pattern can be very useful in other cases.

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Serguei TARASSOV
Hello, What is an explanation why the first code is not good but the second one is good? At least, the first code is three times as shorter and clear. Second code seems to be taken from Delphi 7 where the first one doesn't works. On 28/11/2015 12:00, fpc-pascal-requ...@lists.freepascal.org

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Marcos Douglas
On Sat, Nov 28, 2015 at 7:32 AM, Graeme Geldenhuys wrote: > > Maybe in Luciano's simple example a factory is not the best use case, > but the Simple Factory design pattern can be very useful in other cases. I agree in both affirmations. But as I said before,

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Graeme Geldenhuys
Hi Anthony, On 2015-11-28 00:16, Anthony Walter wrote: > type > IBarkable = interface(IInterface) > ['{B241068F-2ED9-43C7-066B-778B94CB58F9}'] > procedure Bark; > end; > ...snip... That is a much better solution for what Luciano wants to accomplish. > and later ... > > if Animal is

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Juha Manninen
On Sat, Nov 28, 2015 at 1:48 AM, Marcos Douglas wrote: > Another tip: Factories resolve some problems but there is a cost. The > factory will creates your instance (object) but it know only one > constructor, ie, the base class constructor. No, the constructor must then be

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Marco van de Voort
In our previous episode, Marcos Douglas said: > > Inheritance breaks encapsulation. This was written even in GoF Patterns. > There are many post, on the web, explaining why inheritance is evil. > I searched on Google right now: >

Re: [fpc-pascal] mips linux cross compiled application error

2015-11-28 Thread czd
Congratulations for the new fpc compiler and the developers, soon I achieved to compile a simple test program for mips/linux platform. As I wrote before my simple device is onion/omega and here is the cpuinfo and compiled application(attached). It complains with the Illegal instruction replied..

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Juha Manninen
On Sat, Nov 28, 2015 at 2:07 PM, Marcos Douglas wrote: > Even using virtual constructors, the factory will know only one > signature to instantiate objects. Yes and often that is enough. A constructor is then part of the API. (Lets call it API now to avoid confusion with the

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Michael Van Canneyt
On Sat, 28 Nov 2015, Marcos Douglas wrote: Inheritance breaks encapsulation. This was written even in GoF Patterns. There are many post, on the web, explaining why inheritance is evil. I searched on Google right now:

Re: [fpc-pascal] Building kernel modules using fpc (for fun)

2015-11-28 Thread Paul Breneman
On 01/23/2011 08:15 AM, Lukasz Sokol wrote: Lukasz Sokol writes: I decided to put the result of my fiddling back onto the wiki http://wiki.freepascal.org/linux/kernel/module_development as the pastebin seems to have disappeared mysteriously. Enjoy! Lukasz I couldn't find

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Graeme Geldenhuys
On 2015-11-28 19:34, Michael Van Canneyt wrote: > !! OMG !! Maybe we just discovered a new form of multiple inheritance... > Definite proof we should all use C++, or maybe it is time for C+++ !! ROFL - you just made my day. :-) > There is no golden rule which encapsulates (sic) all situations.

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Marcos Douglas
On Sat, Nov 28, 2015 at 3:31 PM, Marco van de Voort wrote: > In our previous episode, Marcos Douglas said: >> >> Inheritance breaks encapsulation. This was written even in GoF Patterns. >> There are many post, on the web, explaining why inheritance is evil. >> I searched on

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Marcos Douglas
On Sat, Nov 28, 2015 at 5:34 PM, Michael Van Canneyt wrote: > > !! OMG !! Maybe we just discovered a new form of multiple inheritance... > Definite proof we should all use C++, or maybe it is time for C+++ !! You have humor, very funny. [clap clap clap] > Please... > >

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread patspiper
On 27/11/15 23:21, luciano de souza wrote: ... But, if this not works, how to implement the Factory Method in Freepascal? What about: var animal: TDog; BEGIN animal := TAnimalFactory.create(atDog); try if animal is TDog then TDog(animal).bark; finally animal.free; end;

Re: [fpc-pascal] Implementing Factory Method with Pascal

2015-11-28 Thread Inoussa OUEDRAOGO
> There is no golden rule which encapsulates (sic) all situations. +1 > People should use their brain and choose a pattern or methodology > judiciously, +1, after all that is what engineering is all about. -- Inoussa O. ___ fpc-pascal maillist -