>Hi Hilmar,
>
>
>>An object based on a class can be created and run in two separate commands, like this:
>
>A)
>>oObject = CreateObject("SomeClass")
>>oObject.Run(par1, par2)
>
>>Or in a single command like this:
>
>B)
>oObject = CreateObject("SomeClass", par1, par2)
>
>>I am assuming that there is a Run() method that does the actual work, and that in the second case, the Init() >method accepts the parameters, and passes them to the Run() method.
>
>>I would like to hear some opinions, on which syntax is preferable.
>
>A) if you call Run() other times on the object life.
>
>B) if you call Run() only first time.
>
>Fabio
Thanks.
I had used option (B) for a long time, for instance for my text-mode report class (download #
9991). But now I am not sure whether this is appropriate. Another reason that occured to me (apart from the ones you gave) is that in option (A), it might be easier to have optional parameters - or to pass parameters "by name", so to speak, by just assigning values to named properties:
oObj = CreateObject("cReportInvoice")
oObj.SortBy = "InvoiceDate"
oObj.FromDate = {^2003-01-01}
oObj.ToDate = {^2003-12-31}
oObj.Run()
This may be easier to read than parameters by position. However, I am not so sure how important this is; but I might eventually make the necessary changes to my text report class.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)