From: E®!k /!sser on
Hi Karl,

>>Well I would strongly advise everybody _not_ to use 'computational logic '
>>inside an ssign or access.
> then why bother writing them at all?

Perhaps we have a different understanding of 'computational logic'.
Thsi is what I do:
I like to hide my class variables for the outside world and I like to be
able to have read- or write only variables.
If for any reason I need to compute or validate a value before it is
assigned, I prefer to use a method. That way the method can return the
validation result.

But I must admit ,if it has to be quick and dirty, I sometimes use an
exported instance variable.

Erik




From: Karl Faller on
Erik,
>If for any reason I need to compute or validate a value before it is
>assigned, I prefer to use a method. That way the method can return the
>validation result.
ok, that i understand. Wonderered why an access shouldn't do work
"inside"...

Karl
From: Meinhard Schnoor-Matriciani on
Hi Erik,

sorry for jumping in ..

> That way the method can return the validation result.

and that's definitely a bad approach !

Regards
Meinhard
From: E®!k /!sser on
Hi Meinhard,

>> That way the method can return the validation result.
>
> and that's definitely a bad approach !

Thanks for sharing your opinion, but could you explain what makes you think
so ?
Let me write a little sample, what is bad (IYO) in this approach?

regards,

Erik

IF SELF:SetValueToVar( 1001 )
... do something
ENDIF

METHOD SetValueToVar( iSuggest AS INT ) AS LOGIC PASCAL CLASS SAMPLE1
LOCAL lReturn AS LOGIC
lReturn := TRUE
IF iSuggest > 20 .AND. iSuggest < 890
SELF:_SomeClassVar := iSuggest
lReturn := FALSE
ENDIF
RETURN lReturn






From: E®!k /!sser on
Oops, code should be like this:

Erik

IF SELF:SetValueToVar( 1001 )
.. do something
ENDIF

METHOD SetValueToVar( iSuggest AS INT ) AS LOGIC PASCAL CLASS SAMPLE1
LOCAL lReturn AS LOGIC
lReturn := FALSE
IF iSuggest > 20 .AND. iSuggest < 890
SELF:_SomeClassVar := iSuggest
lReturn := TRUE
ENDIF
RETURN lReturn

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: Application Icon
Next: VO on a stick