Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Boudewijn Lutgerink
  Where is Boudewijn Lutgerink?
 Hoonaardstraat, Driel
 Netherlands
 Boudewijn Lutgerink
 To: ian pano
  Where is ian pano?
 Metro Manila
 Philippines
 ian pano
 Tags
Subject: RE: creating get and set methods for classes
Thread ID: 155190 Message ID: 155192 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: Classes and Objects
Date: Thursday, December 27, 2007 9:02:11 AM         
   


> dear experts,
>
>
> DEFINE CLASS person as Custom
> 	PROTECTED fname
> 	
> 	PROCEDURE setfName()
> 	LPARAMETERS tcStr
> 		This.Fname = tcStr
> 	ENDPROC
> 	
> 	FUNCTION getfName()
> 		RETURN This.fname 
> 	ENDFUNC
> ENDDEFINE
> 

>
> if i am not mistaken, this is a good practice in OOP, providing an interface for the class users to access or assign a property instead of allowing them to directly manipulate a class' property.
>
> however, is it worth the effort if the class has more than 30 or so properties?
>
>
> tia,
>
> christian pano
> " The bad is entirely my own fault "- Andy Kramek

Keep in mind that the class users mostly are the developers using classes as building blocks for applications.
This means that they have the tools to access your classes as they are. Meaning also that, in case they want to, they can change the property settings as well if they see fit. In that case, as Ken Murphy sometimes says, find a good stick (like a baseball bat) and have a pointy conversation with them.

The end-users of your applications should never be able to access any property of your classes directly as only through the application's logic. Which is, in turn, controlled by the application developer, which brings us back to the first comment. (infinite loop).

And for sure it sometimes is a good practice to keep methods or properties hidden or protected. As it can also be a good practice to keep properties public so they can be accessed through the application when needed.


Boudewijn LutgeĀ®ink
http://www.vfpdevelopers-online.com
Women and Cats just do their own thing, men and dogs should relax and accept this fact of life.

ENTIRE THREAD

creating get and set methods for classes Posted by Christian Pano @ 12/27/2007 7:13:02 AM
RE: creating get and set methods for classes Posted by Vladimir Zhuravlev @ 12/27/2007 7:55:21 AM
RE: creating get and set methods for classes Posted by Boudewijn Lutgerink @ 12/27/2007 9:02:11 AM
RE: creating get and set methods for classes Posted by Cetin Basoz @ 12/27/2007 3:09:00 PM
RE: creating get and set methods for classes Posted by Ken Murphy @ 12/27/2007 4:03:24 PM