100 likes | 218 Views
Florida Community College at Jacksonville. Object-Oriented Concepts Overview. COP 2551 Object-Oriented Programming Spring,2003. Florida Community College at Jacksonville. Objective Overview of Object Orientation Object Attributes and Operations Difference between an object and a class
E N D
Florida Community College at Jacksonville Object-Oriented Concepts Overview COP 2551 Object-Oriented Programming Spring,2003
Florida Community College at Jacksonville • Objective • Overview of Object Orientation • Object Attributes and Operations • Difference between an object and a class • 3 basic Object-oriented principles (Encapsulation, Inheritance and Polymorphism) • Reference: Thinking in Java (Bruce Eckel) • Free download @http://www.BruceEckel.com 2 of 10 slides COP 2551 Object-Oriented Programming OO Concepts Overview
Florida Community College at Jacksonville • Overview of Object Orientation • Object orientation is a technique for system modeling, Object oriented analysis and design, or OOAD, attempts to describe a system as it exists in real life. • The system is modeled as a number of related objectsthat interact. Any system needs objects to do work. It “asks” its objects to do its work, just as you might ask objects in an online store to deliver goods to you and charge the cost to your credit card. • All objects have attributes (characteristics), this is sometimes referred to as state. • They also have operations (or methods), this is sometimes referred to as behavior. 3 of 10 slides COP 2551 Object-Oriented Programming OO Concepts Overview
Florida Community College at Jacksonville • 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 of 10 slides COP 2551 Object-Oriented Programming OO Concepts Overview
Florida Community College at Jacksonville • Object Attributes and Operations • Attributes know something (Attributes are often data, like order ID and customer ID for an Order object. Attributes can also be another object, such as the entire Customer object rather than just the customer ID. • Operations do something with what the attributes know, (Operations can be actions that the object does, often affecting its attributes.) 5 of 10 slides COP 2551 Object-Oriented Programming OO Concepts Overview
Florida Community College at Jacksonville • 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 62467-B is an object of the Book class. 6 of 10 slides COP 2551 Object-Oriented Programming OO Concepts Overview
Florida Community College at Jacksonville • Difference Between Object And Class (continue) • The attributes and operations defined by a class are for its objects, not for itself. There is no concrete realization of the class Book, but there are Book objects, i.e. a class is a logical construct, an object has physical reality. • A class can be compared to a blueprint. Imagine you are in charge of building a housing development, with one housing blueprint. Each house in a development is shaped the same way, but some have brick or aluminum siding, some have custom paint colors inside and some are just white, and so on. 7 of 10 slides COP 2551 Object-Oriented Programming OO Concepts Overview
Florida Community College at Jacksonville • Object-oriented Principle – 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 of 10 slides COP 2551 Object-Oriented Programming OO Concepts Overview
Florida Community College at Jacksonville • Object-oriented Principle - Inheritance • Inheritance is the process by which one object acquires the properties of another object. By use of inheritance, an object need only define all of its characteristics that make it unique within its class, it can inherit its general attributes from its parent. Account Checking Mortgage Loan 9 of 10 slides COP 2551 Object-Oriented Programming OO Concepts Overview
Florida Community College at Jacksonville • Object-oriented Principle – Polymorphism • Polymorphism(from Greek, meaning“many forms”) is a feature that allows one interface to be used for a general class of actions, i.e. one interface, multiple methods. • Example: Account.calculateInterest() 10 of 10 slides COP 2551 Object-Oriented Programming OO Concepts Overview