Classes—Wrapping Data and Behavior Together

Classes are blueprints or specifications for actual objects that we will create in our code. They define a standard set of attributes and behaviors. Because classes only define a structure or intent, they are virtual in nature. For instance, a class cannot hold data, it can't receive a message, and in fact can't do any processing at all. This is because classes are only meant to be object factories. Just like real engineering blueprints of a building, they only exist to construct something else. When we program, this “something else” we are trying to construct is an object. An object can hold data, can receive messages, and can actually carry out processing.

While you don't typically use the term class ...

Get Visual Basic® Programmer's Guide to the .NET Framework Class Library 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.