The document discusses object-oriented programming concepts like classes, objects, properties, methods, constructors, inheritance, polymorphism, and multitier applications. It provides instructions on how to create your own classes in Visual Basic, including defining properties and methods, instantiating objects, and inheriting from base classes.
20. Property Procedure General Form Private ClassVariable As DataType [Public] Property PropertyName( ) As DataType Get Return ClassVariable [PropertyName = ClassVariable] End Get Set (ByVal Value As DataType ) [ statements, such As validation ] ClassVariable = Value End Set End Property
Brief description on how to navigate within this slideshow The first time a Key Term from the chapter is used in the ppt it will display in blue Gold colored text boxes display coding examples Slides will be numbered (# of #) when multiple slides on same topic Speaker notes are included where appropriate for slides (*)Denotes either a comment for page reference to textbook or slide reference in ppt
The next slide provides the coolie analogy describing the relationship of a class and an object
Sometimes the distinction between a method and an event is somewhat fuzzy Generally anything that an object is told to do is a method; if the object does an action and needs to make it known—that’s an event
Key features of an object-oriented language are encapsulation, inheritance, and polymorphism *The next several slides are going to define several object-oriented terms
Think of it being a completed package; all parts of the package are in a capsule Encapsulation can be witnessed by looking at any program; the form is actually a class; all methods and events that are coded are enclosed within the Class and End Class statements; the variables placed in the code are properties of the specific form class being created
The term ploymorphism actually means the ability to take on many shapes or forms
A common practice for writing professional applications is to write independent components that work in multiple “tiers” or layers If one part of the application needs to change, such as a redesign of the user interface or a new database format, the other components do not need to be replaced
The term “n-tier” application is an expansion of the three-tier model The middle tier may be written in multiple classes that can be stored and run from multiple locations
Protected variable behave as private but are available in any class that inherits from this class—as a private or protected variable, the value is available only to procedures within the class, the same way that private module-level varialbe are available only to procedures within a form’s class code
*The next slide displays the Property Procedure General Form
The constructor must be public, because the objects that are created must execute this method If a class does not contain a constructor, the compiler creates an implicit method called the default constructor and has an empty argument list
Creating a new class defines a new type—does not create any objects—
Terminology varies from one OOP language to another-in some languages, shared members are called class variables or static variables Microsoft documentation refers to instance members and shared members, which includes both properties and methods
Using the second technique creates a form class in a different format – the inherited form is created in one file with designer-generated code embedded in the file
The Object Browser is an important tool for working with objects
Available properties, methods, events or constants of a Visual Basic class can be looked up Information such as which elements are defined in the class, what is the base class, and which properties, methods, and events are inherited are displayed *The next slide displays the constants for the MessageBoxButtons
With the chapter step-by-step project open, select the project name in the Object Browser Use the Object Browser to jump to the definition of any property or method by double-clicking on its name in the Members list—this technique is also a great way to jump to any of the procedures in the forms