Dennis Bottjer | ASP.NET + SharePoint Architect, Trainer & Speaker

"An Ounce of Prevention is Worth a Pound of Cure" - Ben Franklin
posts - 168, comments - 59, trackbacks - 41

My Links

News

Add to Technorati Favorites The views expressed in this blog are mine and mine alone, not that of my employer, Microsoft, or anyone else’s. No warrantee is given for the quality of any material on this site.

Tag Cloud

Archives

Post Categories

Power of Properties

Microsoft Developers are familar with properties.  Properties have been part of popular MS development tools such as Visual Basic for several version.  The tradition has continued in .NET with Win/Web forms controls. Developers can manipulate text, font color, font size, etc. via properties.  Perhaps a lesser known fact is that not all OO languages support properties.  Many languages simply support Public Fields.  A field is basically a fancy name for a class instance variable.  Many languages simply make these fields public instead of private or protected.  The danger in this practice is that it violates encapsulation and allows direct access to class data.  Using properties we are able to encapsulate our class data which allows for things such as data validation.  That is when a property is being set, the data being assigned to the property can be validate.  For example, we can make sure that a number or a date falls within a certain range.

Print | posted on Wednesday, July 27, 2005 1:44 AM | Filed Under [ C# & .NET Tutorials ]

Comments have been closed on this topic.

Powered by: