Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adjust line to a declaration
Message
De
08/06/2012 09:08:10
 
 
À
08/06/2012 03:10:06
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01545606
Message ID:
01545649
Vues:
30
>In general I never use public variables - properties are far more flexible:
>
>(a) you can bind to properties but not variables
>(b) you can put validation in one place
>(c) you can add multi-threading support if required.
>(d) properties can be Abstract or Overrideable
>(e) you can restrict property visibility (e.g. with a private setter)

By public variables, you probably meant public properties. Yes, I see some advantages in using the Get/Set approach, such as we described recently in another thread, but whenever this is possible, I like to keep that clean with Public properties as, when comes time to migrate to another environment, this is usually a dropdown conversion instead of trying to migrate something which is too proprietary to the development environment.

>Even when you see no need for any of those initially you may need it later - and you can't just change that in the declaring module without recompiling all other modules that access that item - properties and public variables are not binary compatable....
>
>In C# we have implicit properties (IIRC the equivalent, automatic properties, was added to VB10) which makes using a basic property rather than a variable very simple. Also, in C#, the performance of implicit properties and public variables is the same (I assume the same applies to VB?)
>
>In short there are *no* good reasons to use a public variable.....
>Not just my 10c........ :-}

Thanks for the additional references
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform