Object-Oriented Programming Also known as OOP Based upon the classification model used by people Things are objects that belong to classes Related objects can share attributes (properties) and behavior Tables and desks belong to a class of furniture They share common attributes in that both generally have 4 legs and a large, flat surface on top True OOP languages support Encapsulation Polymorphism Inheritance VB Object-based since it does not support inheritance Regardless, many OOP concepts can still be applied
Classes without Inheritance What do we do if we now provide our employees with email? We need to add that to both classes
Classes with Inheritance What do we do if we now provide our employees with email? We add email to the base class & manager and laborer inherit that attribute
Classes with Multiple Levels of Inheritance
Defining User Objects Add a Class to a Project Add Properties to a Class Create Objects using Instances of a Class Object References Class Events Initialize Event Terminate Event Add Methods
Adding a Class to a Project Add a Class module (different from a module that we used for global declarations and procedures)
Collections vs Arrays A list of objects An array of objects Allows objects to be added at any position Allow objects to be deleted from the middle Objects may be retrieved using a key value more power, more flexible, less efficient An array of objects New objects added to end of array No easy way to allow removal of objects Search code is required to retrieve objects less power, less flexible, more efficient Collections result in simpler, easier-to-read, easier-to-maintain code than object arrays
Collections Processing Create a Collection Retrieve an Object Reference from a Collection Iterate through a Collection Delete an Object Reference from a Collection Delete a Collection