Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #6898 > unrolled thread

Export vs Protect and Access

Started byCMc <cmccaul@ruddwisdom.com>
First post2014-05-25 16:44 -0700
Last post2014-05-28 11:13 -0400
Articles 13 — 8 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Export vs Protect and Access CMc <cmccaul@ruddwisdom.com> - 2014-05-25 16:44 -0700
    Re: Export vs Protect and Access Farid <faridwatson@gmail.com> - 2014-05-25 20:41 -0700
      Re: Export vs Protect and Access CMc <cmccaul@ruddwisdom.com> - 2014-05-26 05:37 -0700
        Re: Export vs Protect and Access Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2014-05-26 15:51 +0200
    Re: Export vs Protect and Access D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2014-05-26 10:17 +0200
      Re: Export vs Protect and Access "Marc Verkade [MITCon]" <marc@mitNOSPAMconDELETE.nl> - 2014-05-26 16:45 +0200
        Re: Export vs Protect and Access D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2014-05-26 17:27 +0200
          Re: Export vs Protect and Access "Marc Verkade [MITCon]" <marc@mitNOSPAMconDELETE.nl> - 2014-05-28 20:47 +0200
    Re: Export vs Protect and Access Massimo Bighelli <info@arcasistemi.it> - 2014-05-26 17:29 +0200
    Re: Export vs Protect and Access "Urs Eggmann" <Urs.Eggmann@shinternet.ch> - 2014-05-26 22:36 +0200
    Re: Export vs Protect and Access "Jamal" <someone@example.com> - 2014-05-27 22:09 -0400
      Re: Export vs Protect and Access Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2014-05-28 07:30 +0200
        Re: Export vs Protect and Access "Jamal" <someone@example.com> - 2014-05-28 11:13 -0400

#6898 — Export vs Protect and Access

FromCMc <cmccaul@ruddwisdom.com>
Date2014-05-25 16:44 -0700
SubjectExport vs Protect and Access
Message-ID<19d01048-056a-41f7-93f6-c11362766a35@googlegroups.com>
Finally making the move from 2.7b to 2.8 and am getting a lot of "Access/Assign method has same name as Protected ivar" compiler errors that I need to clean up.  Can someone tell me what's the difference between:

CLASS MyClass
EXPORT cVar AS STRING

and

CLASS MyClass
PROTECT _cVar AS STRING

ACCESS cVar CLASS MyClass
RETURN SELF:_cVar

Is one more efficient, better for memory management, easier to port to Vulcan?  Other than coding style, why should I use one over the other?

Thanks,
Chris

[toc] | [next] | [standalone]


#6900

FromFarid <faridwatson@gmail.com>
Date2014-05-25 20:41 -0700
Message-ID<3af01967-4212-4c80-b6bf-a4e339232862@googlegroups.com>
In reply to#6898
you mean ...

CLASS MyClassA 
EXPORT cVar AS STRING 

and 

CLASS MyClassB
PROTECT _cVar AS STRING 

ACCESS cVar CLASS MyClassB
RETURN SELF:_cVar 

right?

[toc] | [prev] | [next] | [standalone]


#6902

FromCMc <cmccaul@ruddwisdom.com>
Date2014-05-26 05:37 -0700
Message-ID<e14a0f27-1793-4a51-9685-8031a9cedcbb@googlegroups.com>
In reply to#6900
On Sunday, May 25, 2014 10:41:48 PM UTC-5, Farid wrote:
> you mean ...
> 
> 
> 
> CLASS MyClassA 
> 
> EXPORT cVar AS STRING 
> 
> 
> 
> and 
> 
> 
> 
> CLASS MyClassB
> 
> PROTECT _cVar AS STRING 
> 
> 
> 
> ACCESS cVar CLASS MyClassB
> 
> RETURN SELF:_cVar 
> 
> 
> 
> right?

Really just asking what's the difference between an EXPORT class variable and a PROTECT class variable with an associated ACCESS and ASSIGN method.  Is there some fundamental difference between the two that would make one better to use than the other?  Right now I have an INSTANCE class variable with an associated ACCESS and ASSIGN method of the same name which VO2.8 isn't happy about.  I need to change these to either an EXPORT class variable and remove the associated ACCESS and ASSIGN methods or a PROTECT class variable and change the name of the class variable and modify the ACCESS and ASSIGN methods probably using an underscore (cVar -> _cVar) for the PROTECT class variable.  I think the EXPORT would be simpler coding but don't want to go that route if the PROTECT and associated ACCESS/ASSIGN provides superior performance, memory management, etc.

[toc] | [prev] | [next] | [standalone]


#6904

FromKarl Faller <mail_withoutthat_@_drei-f_andthat_.de>
Date2014-05-26 15:51 +0200
Message-ID<5ih6o99a3g2icl7j8b3p7q2tbpm2co2m6m@4ax.com>
In reply to#6902
Farid,
i doubt there's noticable difference memorywise. The point with
ACC/ASS is, that it allows you to keep a constant "external" interface
while you may change the underlying data at will. The old 2.5 manual
had a very nice explanation of the concept....


Karl

>On Sunday, May 25, 2014 10:41:48 PM UTC-5, Farid wrote:
>> you mean ...
>> 
>> 
>> 
>> CLASS MyClassA 
>> 
>> EXPORT cVar AS STRING 
>> 
>> 
>> 
>> and 
>> 
>> 
>> 
>> CLASS MyClassB
>> 
>> PROTECT _cVar AS STRING 
>> 
>> 
>> 
>> ACCESS cVar CLASS MyClassB
>> 
>> RETURN SELF:_cVar 
>> 
>> 
>> 
>> right?
>
>Really just asking what's the difference between an EXPORT class variable and a PROTECT class variable with an associated ACCESS and ASSIGN method.  Is there some fundamental difference between the two that would make one better to use than the other?  Right now I have an INSTANCE class variable with an associated ACCESS and ASSIGN method of the same name which VO2.8 isn't happy about.  I need to change these to either an EXPORT class variable and remove the associated ACCESS and ASSIGN methods or a PROTECT class variable and change the name of the class variable and modify the ACCESS and ASSIGN methods probably using an underscore (cVar -> _cVar) for the PROTECT class variable.  I think the EXPORT would be simpler coding but don't want to go that route if the PROTECT and associated ACCESS/ASSIGN provides superior performance, memory management, etc.

[toc] | [prev] | [next] | [standalone]


#6901

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2014-05-26 10:17 +0200
Message-ID<lqt5o99qp6p4huq3o1hh4jr1c2iuphksq5@4ax.com>
In reply to#6898
On Sun, 25 May 2014 16:44:22 -0700 (PDT), CMc <cmccaul@ruddwisdom.com>
wrote:

Hello Chris,


>CLASS MyClass
>EXPORT cVar AS STRING
>Is one more efficient, better for memory management, easier to port to Vulcan?  Other than coding style, why should I use one over the other?
>

I can't tell anything about memory management. I think the general
idea of code purists is: the more code, the better, preferably written
such that you can't find out easily how something works or why it
doesn't.

You'll understand that I'd go for Export. It works fine in Vulcan and
saves 50% of the code, so it's at least the most efficient.

Dick

[toc] | [prev] | [next] | [standalone]


#6907

From"Marc Verkade [MITCon]" <marc@mitNOSPAMconDELETE.nl>
Date2014-05-26 16:45 +0200
Message-ID<538353b4$0$30199$6d5eeec5@news.sunnyusenet.com>
In reply to#6901
Hey Dick,

Haha, I do the opposite.
All my instance variables are HIDDEN and I expose them through ACCESS and 
ASSIGN.
So I prevent developers putting data in variables where they shouldn't.

Class XYX
Hidden _MyVar As String

ACCESS MyVar As String Pascal Class XYZ
Return SELF:_MyVar

ASSIGN MyVar(sValue) As String Pascal Class XYZ
Return SELF:_MyVar:=xValue

Greetz, Marc

"D.J.W. van Kooten"  schreef in bericht 
news:lqt5o99qp6p4huq3o1hh4jr1c2iuphksq5@4ax.com...

On Sun, 25 May 2014 16:44:22 -0700 (PDT), CMc <cmccaul@ruddwisdom.com>
wrote:

Hello Chris,


>CLASS MyClass
>EXPORT cVar AS STRING
>Is one more efficient, better for memory management, easier to port to 
>Vulcan?  Other than coding style, why should I use one over the other?
>

I can't tell anything about memory management. I think the general
idea of code purists is: the more code, the better, preferably written
such that you can't find out easily how something works or why it
doesn't.

You'll understand that I'd go for Export. It works fine in Vulcan and
saves 50% of the code, so it's at least the most efficient.

Dick 

[toc] | [prev] | [next] | [standalone]


#6909

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2014-05-26 17:27 +0200
Message-ID<l0n6o95eogevgrrbbdogr0bpdoe15dbh61@4ax.com>
In reply to#6907
On Mon, 26 May 2014 16:45:27 +0200, "Marc Verkade [MITCon]"
<marc@mitNOSPAMconDELETE.nl> wrote:

Hello Marc,

>All my instance variables are HIDDEN and I expose them through ACCESS and 
>ASSIGN.
>So I prevent developers putting data in variables where they shouldn't.


Interesting. I can imagine that you do that if you create a 3rd party
tool and want to prevent that the end user changes an exported
variable which may influence the working of the component, even let it
crash. Willie Moore explained me that he users interfaces to force
users to provide methods in a subclassed control which should be
present for the working.

But I can not imagine the use of such a limitation within a
(reasonably sized) project within 1 company. If one of the developers
think she needs to put data in such a variable he will probably have a
reason for it...

Dick

[toc] | [prev] | [next] | [standalone]


#6921

From"Marc Verkade [MITCon]" <marc@mitNOSPAMconDELETE.nl>
Date2014-05-28 20:47 +0200
Message-ID<53862f75$0$13101$6d5eeec5@news.sunnyusenet.com>
In reply to#6909
Hai Dick,

Next to that, I can control what is put inside a variable...
I just do not like to have no control ;-)

Consider this:

Assign RightAlignedString(sValue) class XYZ
Do case
Case Emtpy(sValue)
  // Leave the old value
Otherwise
  sValue:=PadL(sValue,10)
  self:_RightAlignedString := sValue
End
Return self:_RightAlignedValue

Grtz, Marc

"D.J.W. van Kooten"  schreef in bericht 
news:l0n6o95eogevgrrbbdogr0bpdoe15dbh61@4ax.com...

On Mon, 26 May 2014 16:45:27 +0200, "Marc Verkade [MITCon]"
<marc@mitNOSPAMconDELETE.nl> wrote:

Hello Marc,

>All my instance variables are HIDDEN and I expose them through ACCESS and
>ASSIGN.
>So I prevent developers putting data in variables where they shouldn't.


Interesting. I can imagine that you do that if you create a 3rd party
tool and want to prevent that the end user changes an exported
variable which may influence the working of the component, even let it
crash. Willie Moore explained me that he users interfaces to force
users to provide methods in a subclassed control which should be
present for the working.

But I can not imagine the use of such a limitation within a
(reasonably sized) project within 1 company. If one of the developers
think she needs to put data in such a variable he will probably have a
reason for it...

Dick 

[toc] | [prev] | [next] | [standalone]


#6910

FromMassimo Bighelli <info@arcasistemi.it>
Date2014-05-26 17:29 +0200
Message-ID<llvmkg$huh$3@speranza.aioe.org>
In reply to#6898

as Mark pointed out:
Encapsulation

*Massimo Bighelli* ARCA Sistemi S.r.l.

[toc] | [prev] | [next] | [standalone]


#6913

From"Urs Eggmann" <Urs.Eggmann@shinternet.ch>
Date2014-05-26 22:36 +0200
Message-ID<buhmutFa1jvU1@mid.individual.net>
In reply to#6898
Hi Chris,

As Marc wrote, with EXPORT you violate (at least a little) the principle of 
class encapsulation. With properly programmed access and assign methods you 
have a defined interface to the class variables and the possibility to do 
some checking of transferred values. I prefer Marcs method with the 
underscore.

regards
Urs

"CMc" <cmccaul@ruddwisdom.com> schrieb im Newsbeitrag 
news:19d01048-056a-41f7-93f6-c11362766a35@googlegroups.com...
> Finally making the move from 2.7b to 2.8 and am getting a lot of 
> "Access/Assign method has same name as Protected ivar" compiler errors 
> that I need to clean up.  Can someone tell me what's the difference 
> between:
>
> CLASS MyClass
> EXPORT cVar AS STRING
>
> and
>
> CLASS MyClass
> PROTECT _cVar AS STRING
>
> ACCESS cVar CLASS MyClass
> RETURN SELF:_cVar
>
> Is one more efficient, better for memory management, easier to port to 
> Vulcan?  Other than coding style, why should I use one over the other?
>
> Thanks,
> Chris 

[toc] | [prev] | [next] | [standalone]


#6918

From"Jamal" <someone@example.com>
Date2014-05-27 22:09 -0400
Message-ID<lm3ggc$n46$1@speranza.aioe.org>
In reply to#6898
EXPORT variables will always be faster than access/assign since you do not 
have the overhead of extra method calls.
I would only use access/assign if a block of code is needed to assign or 
return a value.

INSTANCE variables are the slowest.

From the help file:
Since there is no need for a runtime lookup with early bound instance 
variables, using them instead of late bound variables will significantly 
improve the performance of your application.  The following table summarizes 
the binding and visibility issues for the four types of instance variables:

Variable Type Binding        Visibility

EXPORT Early, if possible        Application-wide for CLASS and module-wide 
for STATIC CLASS

INSTANCE Always late        In class and subclasses

HIDDEN Always early        In class only

PROTECT Always early        In class and subclasses

HTH,
Jamal


"CMc"  wrote in message 
news:19d01048-056a-41f7-93f6-c11362766a35@googlegroups.com...

Finally making the move from 2.7b to 2.8 and am getting a lot of 
"Access/Assign method has same name as Protected ivar" compiler errors that 
I need to clean up.  Can someone tell me what's the difference between:

CLASS MyClass
EXPORT cVar AS STRING

and

CLASS MyClass
PROTECT _cVar AS STRING

ACCESS cVar CLASS MyClass
RETURN SELF:_cVar

Is one more efficient, better for memory management, easier to port to 
Vulcan?  Other than coding style, why should I use one over the other?

Thanks,
Chris 

[toc] | [prev] | [next] | [standalone]


#6919

FromKarl Faller <mail_withoutthat_@_drei-f_andthat_.de>
Date2014-05-28 07:30 +0200
Message-ID<mjsao9hr40r37jlfegd9pvbeth3niq40v2@4ax.com>
In reply to#6918
Jamal et all,
nothing wrong with Export. But it was a great achievement, to be able
to put Acc/ass in front of them - as you ever can do, if need arises.
Problem is, programmers are men, and men are lazy, so often they
rather add methods instead of changing from Export to A/A.
Just a sample: in one app i have a logic db-field, called Abo,
initially this only had to to hold, if some property was true or
false, UI-wise controlled by a checkbox .  Later on, i had to provide
background activity bound to this, so i used the A/A and what
initially was a
Assign Abo(uValue)
Return 

changed to something like: 
ASSIGN Abo( uValue )      
LOCAL cSearch AS STRING                                   
LOCAL lSet AS LOGIC
IF uValue
	lSet:= TRUE
ELSE
	lSet:= FALSE
ENDIF

cSearch:= SELF:BLOCK-PadL(AllTrim(SELF:REIHE), 2,
"0")-PadL(AllTrim(SELF:PLATZ), 2, "0")
IF SLen(AllTrim(cSearch)) =5 
	IF SELF:ConnectWithSeats(cSearch, lSet, SELF:PNo)         
		SELF:RLOCK()
		SUPER:ABO:=uValue
		SELF:Commit()	   
		SELF:UnLock(SELF:RecNo) 
		IF SLen(AllTrim(SELF:RECMASTER)) > 0 			IF lSet
				LOCAL nRetVal AS WORD
				nRetval:=JNoderPrompt("Kategorie " + SELF:KAT + " ok (Ja)",
"oder in Schüler- (Nein)  oder FreiAbo (Abbrechen) ändern?")
				IF nRetVal = 2 // ändern 					SELF:RLOCK()
					SELF:KAT:="3"
					SELF:Commit()
					SELF:unlock()
				ELSEIF nRetVal = 3
					SELF:RLOCK()
					SELF:KAT:="0"
					SELF:Commit()
					SELF:unlock() 
				ENDIF
			ENDIF		
			SELF:ReCalcAboSum(SELF:RECMASTER)  
		ENDIF
	ENDIF
ELSE
	Meldung("FEHLER!",  "Keine Platzdaten eingetragen!  " +  cSearch)
	SELF:Skip(0)  wird
ENDIF
RETURN

Quite some functionality added, but UI-wise nothing changed at all!

BTW, i use this app myself, didn't notice any change speedwise...

Karl


>EXPORT variables will always be faster than access/assign since you do not 
>have the overhead of extra method calls.
>I would only use access/assign if a block of code is needed to assign or 
>return a value.
>
>INSTANCE variables are the slowest.
>
>From the help file:
>Since there is no need for a runtime lookup with early bound instance 
>variables, using them instead of late bound variables will significantly 
>improve the performance of your application.  The following table summarizes 
>the binding and visibility issues for the four types of instance variables:
>
>Variable Type Binding        Visibility
>
>EXPORT Early, if possible        Application-wide for CLASS and module-wide 
>for STATIC CLASS
>
>INSTANCE Always late        In class and subclasses
>
>HIDDEN Always early        In class only
>
>PROTECT Always early        In class and subclasses
>
>HTH,
>Jamal
>
>
>"CMc"  wrote in message 
>news:19d01048-056a-41f7-93f6-c11362766a35@googlegroups.com...
>
>Finally making the move from 2.7b to 2.8 and am getting a lot of 
>"Access/Assign method has same name as Protected ivar" compiler errors that 
>I need to clean up.  Can someone tell me what's the difference between:
>
>CLASS MyClass
>EXPORT cVar AS STRING
>
>and
>
>CLASS MyClass
>PROTECT _cVar AS STRING
>
>ACCESS cVar CLASS MyClass
>RETURN SELF:_cVar
>
>Is one more efficient, better for memory management, easier to port to 
>Vulcan?  Other than coding style, why should I use one over the other?
>
>Thanks,
>Chris 

[toc] | [prev] | [next] | [standalone]


#6920

From"Jamal" <someone@example.com>
Date2014-05-28 11:13 -0400
Message-ID<lm4uf0$5n2$1@speranza.aioe.org>
In reply to#6919
Karl,

I did not say there anything wrong with EXPORT variables!
To clarify: Access/Assign should only be used with other variables types 
other than EXPORT, like PROTECT. If a programmer needs ACCESS/ASSIGN to 
provide encapsulation and additional variable manipulation, that's fine.

EXPORT variables are extremely useful and can eliminate lots of generated 
code by the Windows Editor especially if windows controls need to accessed 
or assigned. That's why this feature was added to VO ( I think starting 
2.0).
For example: if you have 20 controls like SLEs, with EXPORT: you will have 
20 declaration in the class, however, with PROTECT variables, you will have 
20 declarations, 20 ACCESS methods and 20 ASSIGN methods.  This an overhead 
that is not needed that can really bloat the app when you have many windows.

Jamal

Regarding speed, I am going by what the help file says about "early bound".

"Karl Faller"  wrote in message 
news:mjsao9hr40r37jlfegd9pvbeth3niq40v2@4ax.com...

Jamal et all,
nothing wrong with Export. But it was a great achievement, to be able
to put Acc/ass in front of them - as you ever can do, if need arises.
Problem is, programmers are men, and men are lazy, so often they
rather add methods instead of changing from Export to A/A.
Just a sample: in one app i have a logic db-field, called Abo,
initially this only had to to hold, if some property was true or
false, UI-wise controlled by a checkbox .  Later on, i had to provide
background activity bound to this, so i used the A/A and what
initially was a
Assign Abo(uValue)
Return

changed to something like:
ASSIGN Abo( uValue )
LOCAL cSearch AS STRING
LOCAL lSet AS LOGIC
IF uValue
lSet:= TRUE
ELSE
lSet:= FALSE
ENDIF

cSearch:= SELF:BLOCK-PadL(AllTrim(SELF:REIHE), 2,
"0")-PadL(AllTrim(SELF:PLATZ), 2, "0")
IF SLen(AllTrim(cSearch)) =5
IF SELF:ConnectWithSeats(cSearch, lSet, SELF:PNo)
SELF:RLOCK()
SUPER:ABO:=uValue
SELF:Commit()
SELF:UnLock(SELF:RecNo)
IF SLen(AllTrim(SELF:RECMASTER)) > 0 IF lSet
LOCAL nRetVal AS WORD
nRetval:=JNoderPrompt("Kategorie " + SELF:KAT + " ok (Ja)",
"oder in Schüler- (Nein)  oder FreiAbo (Abbrechen) ändern?")
IF nRetVal = 2 // ändern SELF:RLOCK()
SELF:KAT:="3"
SELF:Commit()
SELF:unlock()
ELSEIF nRetVal = 3
SELF:RLOCK()
SELF:KAT:="0"
SELF:Commit()
SELF:unlock()
ENDIF
ENDIF
SELF:ReCalcAboSum(SELF:RECMASTER)
ENDIF
ENDIF
ELSE
Meldung("FEHLER!",  "Keine Platzdaten eingetragen!  " +  cSearch)
SELF:Skip(0)  wird
ENDIF
RETURN

Quite some functionality added, but UI-wise nothing changed at all!

BTW, i use this app myself, didn't notice any change speedwise...

Karl


>EXPORT variables will always be faster than access/assign since you do not
>have the overhead of extra method calls.
>I would only use access/assign if a block of code is needed to assign or
>return a value.
>
>INSTANCE variables are the slowest.
>
>From the help file:
>Since there is no need for a runtime lookup with early bound instance
>variables, using them instead of late bound variables will significantly
>improve the performance of your application.  The following table 
>summarizes
>the binding and visibility issues for the four types of instance variables:
>
>Variable Type Binding        Visibility
>
>EXPORT Early, if possible        Application-wide for CLASS and module-wide
>for STATIC CLASS
>
>INSTANCE Always late        In class and subclasses
>
>HIDDEN Always early        In class only
>
>PROTECT Always early        In class and subclasses
>
>HTH,
>Jamal
>
>
>"CMc"  wrote in message
>news:19d01048-056a-41f7-93f6-c11362766a35@googlegroups.com...
>
>Finally making the move from 2.7b to 2.8 and am getting a lot of
>"Access/Assign method has same name as Protected ivar" compiler errors that
>I need to clean up.  Can someone tell me what's the difference between:
>
>CLASS MyClass
>EXPORT cVar AS STRING
>
>and
>
>CLASS MyClass
>PROTECT _cVar AS STRING
>
>ACCESS cVar CLASS MyClass
>RETURN SELF:_cVar
>
>Is one more efficient, better for memory management, easier to port to
>Vulcan?  Other than coding style, why should I use one over the other?
>
>Thanks,
>Chris 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web