Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Losing Focus
Message
 
To
10/11/2001 10:39:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00580131
Message ID:
00580149
Views:
18
>Cetin,
>
>Do I just give the value of my parameter to the property? What advatage is this?

Steve,

I am sure Cetin will answer you from his perspective, but let me give you some insignt as to why public variables are a bad idea.

The ONLY reason for a variable to be public is for it to live beyond the method or procedure that creates it. This, by nature, means that some code is going to use that variabel when it has no control over the variable's creation or assignment. This si a poor design as it is pen to all kinds of problems.

Second, you cannot declare a variable public if it already exists, so the second time you run your form you will get an error at the public declaration.

Using a property is better because the property belongs to teh object. A public variabel is flosting around in memory not belonging to anything and possibly stepping on other things.

Imagine a team of programmers working on a project, you create a public variable named Number. The another programmer working on another part of the app needs a private variable and he uses the name Number, but he is now using your public variable totally unknown to him because you created the public var.

Using a property of an object is better because the property is totally contained within the object and doesn't effect any other code anywhere.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform