Sunteți pe pagina 1din 47

Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.

Net
WiBit.net
Introduction to Object Oriented
Programming
Getting Started
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
What is OOP? (Informal)
A programming method or style that uses
custom data types
Instead of only having variable data
types, such as Integer and Char, we can
now make a new data type (Ex: Frog)
A Frog data type (object) can also
contain a function (method) such as
Speak
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
What is OOP? (Formal)
A programming method of using data
structures that contain methods
(functions) and fields (attributes)
Object is synonymous with
Class
Interface
Note: In some languages there is a difference
between class and interface
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
The Basics
Frog
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
The Basics
Frog
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
The Basics
Frog
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
The Basics
Frog
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
What is OOP?
Two types of OOP Languages
Support OOP
Procedural Language that has an OOP component
built in or bolted on
Examples
C++
Objective C
Pure OOP
Language that is natively OOP
Examples
Java
C#
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Similarity To Non-OOP Languages
Classes are similar to Structures & Unions
Fundamental Differences
Classes have their own Functions
Classes can contain data that is Private and/or
Protected
Classes can inherit from other classes to absorb
functionality
Each class acts as its own entity completely
separate from the rest of the program
Sort of like a program in a program
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Modularity Model Vs OOP Model
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Modularity Model Vs OOP Model
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Modularity Model Vs OOP Model
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Modularity Model Vs OOP Model
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Modularity Model Vs OOP Model
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Modularity Model Vs OOP Model
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Modularity Model Vs OOP Model
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Modularity Model Vs OOP Model
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Modularity Model Vs OOP Model
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Message Passing
Aka. Interfacing
The process of objects invoking methods
within another object
method
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
How Objects are Composed
Main Class
Just like in C, our programs need to begin
somewhere!
Note: Not all OOP languages use the Main Class concept. Most notable, some
scripting languages (such as Perl) have their own way of deciding where the
program entry point is. These are most often referred to as Dynamic
Programming Languages.
Supporting Classes
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Objects are often described as an
Encapsulation of methods and attributes
How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Objects are often described as an
Encapsulation of methods and attributes
How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Objects are often described as an
Encapsulation of methods and attributes
How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Objects are often described as an
Encapsulation of methods and attributes
How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Objects are often described as an
Encapsulation of methods and attributes
How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Objects are often described as an
Encapsulation of methods and attributes
How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Review (Remember the Person example)
Object
Potential
Concept of a Person
Instance
Entity
The Actual Person

How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Members
Anything that belongs to a class
Fields
Methods
Properties
Delegates
How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Fields
Also called
Attributes
Properties (incorrect terminology)
Members of an object that are data types
Integers
Strings
Other objects
Etc

How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Methods
Functions that belong to an object
In reference to OOP, all functions must be
called Methods (very important)
Its sort of like the difference between a car
and a truck. The differences may seem
subtle, but the two words mean something
very different
How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Methods
Functions that belong to an object
How Objects are Composed
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Methods
Functions that belong to an object
How Objects are Composed
Main()
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Methods
Functions that belong to an object
How Objects are Composed
MyObject
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Methods
Functions that belong to an object
How Objects are Composed
MyObject
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Two types of members
Class Level Access (Static)
Belong to the object and not the instance
Example: As a human, the world population is NOT a
property of a human, it is a property of all humans
Instance Level Access (Non-Static)
Belong to the instance and not the object
Example: As a human, date of birth is NOT a property
of all humans, it is a property of a human (or groups of
humans)
How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
Access Levels
Public
Accessible to all code everywhere!
Private
Can only be accessed by the object or friendly
functions
Protected
Accessible to the object and other objects that
inherit from the object
How Objects are Composed
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
How Objects are Composed
Object Type
Public
Attribute Attribute Attribute
Static Attribute Static Attribute
Constructor Destructor Method Method
Static
Method
Private
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method Method
Static
Method
Static
Method
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
How Objects are Composed
Object Type
Public
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method
Static
Method
Private
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method Method
Static
Method
Static
Method
Public Members
Accessible to all external
code.

Constructor Destructor
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
How Objects are Composed
Object Type
Public
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method
Static
Method
Private
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method Method
Static
Method
Static
Method
Private Members
Accessible to code within
the Class.

Constructor Destructor
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
How Objects are Composed
Object Type
Public
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method
Static
Method
Private
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method Method
Static
Method
Static
Method
Attribute Members
Aka. Instance Level Access
Data types that retain
values relevant to the
object instance.
Constructor Destructor
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
How Objects are Composed
Object Type
Public
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method
Static
Method
Private
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method Method
Static
Method
Static
Method
Static Attribute Members
Aka. Class Level Access
Data types that retain
values relevant to the
object itself.

Constructor Destructor
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
How Objects are Composed
Object Type
Public
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method
Static
Method
Private
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method Method
Static
Method
Static
Method
Methods
Functions that belong
to the object instance.

Constructor Destructor
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
How Objects are Composed
Object Type
Public
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method
Static
Method
Private
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method Method
Static
Method
Static
Method
Static Methods
Functions that belong
to the object itself.

Constructor Destructor
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
How Objects are Composed
Object Type
Public
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method
Static
Method
Private
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method Method
Static
Method
Static
Method
Constructor
Method that executes
automatically when a
new instance is created.

Constructor Destructor
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
How Objects are Composed
Object Type
Public
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method
Static
Method
Private
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method Method
Static
Method
Static
Method
Destructor
Method that executes
automatically when an
existing instance is
destroyed.

Constructor Destructor
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
Introduction to Object Oriented
Programming
How Objects are Composed
Object Type
Public
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method
Static
Method
Private
Attribute Attribute Attribute
Static Attribute Static Attribute
Method Method Method
Static
Method
Static
Method
Constructor Destructor
Object
Copyright BlueSignet LLC. All rights reserved. For more visit WiBit.Net
WiBit.net
The End?
Thank You For Watching!

S-ar putea să vă placă și