Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Oriented Programming Intermediate VB Doug Waterman Fox Valley Technical College.

Similar presentations


Presentation on theme: "Object Oriented Programming Intermediate VB Doug Waterman Fox Valley Technical College."— Presentation transcript:

1 Object Oriented Programming Intermediate VB Doug Waterman Fox Valley Technical College

2 What is OOP 4 A way of programming based on the things (objects) involved. 4 It’s a way to solve problems.

3 What is an object? 4 An object is a high-level design item. –If you are an architect, you deal with the following objects working space foundation plumbing HVAC –The architect doesn’t think about how the concrete for the foundation will be poured. This would be a lower level design item.

4 What is an object in programming? 4 Objects are things. –People –companies –employees –time sheets –ledger entries –business requirements 4 An object refers to the specific thing.

5 Elements of an Object Oriented System 4 Abstraction 4 Encapsulation 4 Inheritance 4 Polymorphism

6 Abstraction 4 Abstraction is used to identify the objects involved with a particular application. 4 Allows you to focus on the objects of an application and not on the implementation. 4 It exposes the design of a system without involving the technological issues. 4 Allows the users to become key participants in the design process.

7 Abstraction Example Sees the tree as a place to perch. Sees the tree as a place to.. well you know! Sees the tree as a fun thing to climb.

8 Encapsulation 4 Building internal information (properties) and operating procedures (methods) into an object. 4 Internal information is held within the object. External procedures don’t know how a function performs. –Example: How does the cbo.Item.Add Method work for a ComboBox? –We don’t care!

9 Inheritance 4 There are two types of inheritance.  Interface Inheritance  What properties and methods will you expose to programs that use your class?  Implementation Inheritance  How will programs be able to access your class  Read Only  Read/Write

10 Polymorphism 4 Two or more classes can have the ability to have behaviors that are named the same, have the same basic purpose but different implementations. –Both an Instructor and a MicrosoftCEO object will have a “CalculatePay” behavior but the implementation (underlying code) can be very different.

11 What are Classes A class is a group of similar objects. –A cookie cutter would be an example of a class. –The cookies that are made using the cookie cutter are objects. –You eat the cookie (object) but not the cookie cutter (class). –Each cookie starts out exactly like every other cookie. You adjust the size, shape, frosting and topping that go on the cookie. This makes the object unique.

12 Where Do Properties, Fields and Methods Fit In? 4 An object has properties and methods. The list of properties and methods define the class interface. –A command button in the toolbox is an example of a class. –A command button you place on a form is an example of an object derived from a class. 4 Properties and Fields are the “nouns” of an object, they hold information. 4 Methods are the action items- the “verbs”.

13 Example Class Customer Class

14 Example Class: Define Data Elements Last Name First Name Address Phone Fax Web Site Customer Class

15 Example Class: Define Actions Last Name First Name Address Phone Fax Web Site Call View Send ActionComplete Customer Class

16 Example Class: Define Default Interface Last Name First Name Address Phone Fax Web Site Call View Send ActionComplete Customer Class Default Interface Incoming Outgoing

17 Example Class: Instantiate Object from Class Customer Object 1 Last Name First Name Address... Default Interface Incoming Outgoing Customer Object 2 Last Name First Name Address... Default Interface Incoming Outgoing m_Customer1 m_MyCustomer m_Customer2 You can have multiple pointers referencing the same object.

18 Example Class: Create a Collection of Objects Customer Object 1 Last Name First Name Address... Default Interface Incoming Outgoing Customer Object 2 Last Name First Name Address... Default Interface Incoming Outgoing m_Customer1 m_MyCustomer m_Customer2 You can have multiple pointers referencing the same object. m_ colCustomers

19 Class Hierarchy Employee InstructorIntern Class Subclass The Intern is a subclass of Employee and inherits all of the behaviors and properties of Employee.

20 Objects as Containers Objects can be composed of other objects. Employees Intern AlbertIntern BobIntern SueIntern Ann 1/8/99 Timesheet 1/15/99 Timesheet 1/22/99 Timesheet 1/29/99 Timesheet  Collection of Employee  Collection of Timesheet

21 Terminology 4 Class - a unit of source code with one or many interfaces. Some of these interfaces may be specified as public for external use. 4 Object - a run-time instantiation of a class that is packaged within a component. 4 Properties - data that the class maintains internally. These may be visible for external use (either setting or viewing) or private for use inside the class.

22 Terminology 4 Fields – Similar to properties – but you can’t control how the user accesses the data. 4 Methods - The actions that are defined for an object. The default events that are part of a VB object are New and Finalize. New is run when an object is instantiated from the base class. Finalize is run prior to releasing the objects memory back to the system.

23 Terminology 4 Event - A message, broadcast from within an object. 4 Interface - The list of properties and methods available for external use. An object may have more than one interface. 4 Collection - A set of pointers to related objects.


Download ppt "Object Oriented Programming Intermediate VB Doug Waterman Fox Valley Technical College."

Similar presentations


Ads by Google