Fields and Properties
You have seen what a property is and why you need properties. A normal class should have all its attributes implemented using a combination of private fields and public (or friend) properties. In some cases it may be useful to give access to the class fields to classes in the same assembly as itself. In this case you can use friend fields and public properties. That would ensure that no one outside the assembly has access to the class internals.
Using public fields is the only big no-no. It would break the encapsulation principle, which is one of the most important OO principles.
In UML notation, the class attributes normally represent both the property and the field. The attribute specification will indicate whether a combination ...
Get Visual Basic® .NET by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.