Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object-Oriented Programming

Similar presentations


Presentation on theme: "Object-Oriented Programming"— Presentation transcript:

1 Object-Oriented Programming
Classes, Objects & Encapsulation (oh my)

2 What is Object Orientation?
Object orientation is a technique for system modeling Modeling tries to simulate real life Objects within a system interact with each other (hence ERDs) eg. Object Student could be expected to deliver their homework to Object Teacher who will mark it. All objects have attributes (characteristics), this is sometimes referred to as state. They also have methods (or functions), this is sometimes referred to as behavior. I’m not real

3 Examples of Objects Use an online store (such as amazon.com) as an example, the following things may consider as Objects: Book Customer Order

4 Object Attributes and Operations
Attributes know something Attributes are often data, like order ID. Attributes can also be another object, such as the entire Customer object rather than just the customer ID. Methods do something with what the attributes know, (Methods can be actions that the object does, often affecting its attributes.)

5 Difference Between Object And Class
A class is how you define an object. Classes are descriptive categories or templates. Book could be a class. Objects are unique instances of classes. This Java Certification book that costs $59.99 with item ID B is an object of the Book class.

6 The attributes and methods defined by a class are for its objects, not for itself.
There is no actual Book, but there are Book objects The class is the logical concept of a Book The object is Great Expectations

7 Encapsulation Encapsulation is the mechanism that binds together the code and the data it manipulates, and keeps both safe from outside interference and misuse. A Class Public variables and methods Private variables and methods Public variables is not recommended

8 Inheritance Inheritance is the process by which one object acquires the attributes of another object. By use of inheritance, an object need only define all of its attributes that make it unique within its class, it can inherit its general attributes from its parent. Account Current Savings Loan

9 Polymorphism Polymorphism(from Greek, meaning “many forms”)
function Animal(name) { this.name = name; this.talk = function () { return ""; }; } function Cat(name) { Animal.call(this, name); this.talk = function() { return "Meow!!!"; }; function Dog(name) { return "Woof! Woof!"; };


Download ppt "Object-Oriented Programming"

Similar presentations


Ads by Google