On Fri, Jul 17, 2015 at 3:06 AM, Graeme Geldenhuys < mailingli...@geldenhuys.co.uk> wrote:
> On 2015-07-17 03:34, silvioprog wrote: > > TPersonDao = class(TObject) > > public > > procedure Save(APerson: TObject); > > end; > > Simply change that to the following: > > TPersonDao = class(TObject) > public > procedure Save(APerson: TPerson); > end; > Yes, it was just a simple and partial demo, but have you seen the following sample in same e-mail that I sent? Using the generics I could do a generic DAO that could be used by any class, avoiding TPersonDAO, TProductDAO, TOtherMyEntityDAO and providing a simple and useful CRUD layer: just specialize it using a model, something like TSession.Persist/Retrieve/Modify/Purge/Paginate<TMyEntity>. Generics are very usefeul, the problem is just the way how something it is used in some implementation, e.g, using the FGL AFAIK you cannot know the type of the item from a specializated list class. and you could have compile time validation too. Using TObject as the > parameter type is just too generic (excuse the pun). ;-) OK, no problem. =) BTW I use correct type as parameters, but I believe you understood what I meant. =D -- Silvio Clécio My public projects - github.com/silvioprog
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal