[fpc-pascal] methods of an object to create others objects

Marcos Douglas md at delfire.net
Tue Jul 6 22:14:38 CEST 2010


On Tue, Jul 6, 2010 at 4:09 PM, Reimar Grabowski <reimgrab at web.de> wrote:
> On Tue, 6 Jul 2010 14:54:29 -0300
> Marcos Douglas <md at delfire.net> wrote:
>
>> Like obj1.CreateObj() ? =)
> Sounds a little generic for my liking, but at least you can guess that
> there is something more going on than just returning a value, so, yes. :)
> I'd rather use something like obj2 := obj1.CreateSpecialTMyObjectInstance(); myself, which
> explains why I cannot use a default constructor to create obj2. But in the end it is all about personal style.

Well... I think use a name as CreateSpecialTMyObjectInstance() is very
especific... but, as you said, in the end it is all about personal
style.

I think found a better way to my example. Instead to create an object
using Parser.CreateMyObj(ATxt), e.g., maybe is better have an object
(TMyObj) instantiated in Parser and the name of method would be
Parser.GetMyObj(ATxt). The Parser fill the FMyObj field (atributte)
using the ATxt parameter. Like as DataSet.FieldByName('column_name')
returns a TField object.

I use this style a lot, but I wanted to hear some better ideas.


MD.



More information about the fpc-pascal mailing list