Object-oriented Programming Concepts

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

By Waqas Over the many years the people have studied software-development approaches to figure out which approaches are quickest, cheapest, most.
General OO Concepts Objectives For Today: Discuss the benefits of OO Programming Inheritance and Aggregation Abstract Classes Encapsulation Introduce Visual.
When is Orientated Programming NOT? Mike Fitzpatrick.
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
Computer Science Dept. Fall 2003 Object models Object models describe the system in terms of object classes An object class is an abstraction over a set.
BITS Pilani Avinash Gautam Department of Computer Science and Information Systems.
Classes & Objects Computer Science I Last updated 9/30/10.
Inheritance Java permits you to use your user defined classes to create programs using inheritance.
1 Object-Oriented Programming Concepts. 2 Recap from last lecture Variables and types –int count Assignments –count = 55 Arithmetic expressions –result.
What is an object? Your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior;
EEC-681/781 Distributed Computing Systems Java Tutorial Wenbing Zhao Cleveland State University
OBJECT ORIENTED ANALYSIS & DESIGN Vassilka Kirova Department of Computer & Information Science NJIT.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
BACS 287 Basics of Object-Oriented Programming 1.
1 Pertemuan 6 Object Oriented Programming Matakuliah: T0053/Web Programming Tahun: 2006 Versi: 2.
Object-Oriented Programming Concepts
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized.
An Object-Oriented Approach to Programming Logic and Design
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
Object Oriented Programming Principles Lecturer: Kalamullah Ramli Electrical Engineering Dept. University of Indonesia Session-3.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Object Oriented Software Development
Lecture 12 March 16, The Scope of a Variable What if there are two variables with the same name? –A local or block-local variable can have the same.
Object-Oriented Programming •Object-Oriented Programming (OOP) allows you to create your program based upon modeling objects.  Your program’s properties.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
CSC 131 Fall 2006 Lecture # 6 Object-Oriented Concepts.
Abstraction ADTs, Information Hiding and Encapsulation.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Object-Oriented Programming. Objectives Distinguish between object-oriented and procedure-oriented design. Define the terms class and object. Distinguish.
© 2007 Lawrenceville Press Slide 1 Chapter 8 Objects  A variable of a data type that is a class. Also called an instance of a class.  Stores data  Can.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
JAVA Programming (Session 4) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
1 Software Engineering Lecture 15 Object Oriented Software Design in Java.
Object-Oriented Principals Dwight Deugo Nesa Matic
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Classes, Interfaces and Packages
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
By : Robert Apeldorn. What is OOP?  Object-oriented programming is a programming paradigm that uses “objects” to design applications and computer programs.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
COP 4331 – OOD&P Lecture 7 Object Concepts. What is an Object Programming language definition: An instance of a class Design perspective is different.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
1 n Object Oriented Programming. 2 Introduction n procedure-oriented programming consists of writing a list of instructions and organizing these instructions.
Object Oriented Programming in Java Habib Rostami Lecture 2.
 The word static is used to declare either a ________ variable or method.  Why do we use statics?  What is Polymorphism? class In general, we use a.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
 The Object Oriented concepts was evolved for solving complex problems. Object- oriented software development started in the 1980s. Object-oriented design.
Object-Oriented Programming
Programming paradigms
Sections Inheritance and Abstract Classes
JAVA By Waqas.
University of Central Florida COP 3330 Object Oriented Programming
University of Central Florida COP 3330 Object Oriented Programming
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Programming paradigms
Object Oriented Analysis and Design
Object-Oriented Programming
Presentation transcript:

Object-oriented Programming Concepts

What is an object ? Real-world objects: Software objects: All have state and behavior Bicycles have state: current gear, two wheels, number of gears... Bicycles have behavior: braking, accelerating, changing gears... Software objects: Also have state and behavior Maintains its state in variables Implements its behavior in methods

Definition An object is a software bundle of variables and related methods. Software objects can: represent real-world objects, such as a bicycle represent abstract concepts, such as an "Event" object in a window system

Encapsulation Anything that an object does not know or cannot do is excluded from the object. Encapsulation is used to hide unimportant implementation details from other objects. Implementation details of an object can be changed at any time without affecting other parts of the program. Definition: Packaging an object's variables within the protective custody of its methods is called encapsulation.

Benefits of Encapsulation Modularity Source code can be written and maintained independently An object can be passed easily around Information hiding An object has a public interface for other objects to communicate with. An object can maintain private information and methods that can be changed without affecting other objects.

Examples When you want to change gears on your bicycle, you don't need to know how the gear mechanism works, you just need to know which lever to move. With software objects, you don't need to know how a method is implemented, you just need to know which method to invoke and its interface.

Messages A single object is a component of a larger program that contains many other objects. Application functionality is achieved by interactions of these objects. Software objects interact and communicate with each other by sending messages to each other.

Messaging

Components of a message The object to whom the message is addressed. (Your Bicycle) The name of the method to perform. (changeGears) Any parameters needed by the method. (lower gear)

What are classes? Your bicycle Your bicycle is just one of many bicycles in the world. Bicycle have some state and behavior in common. However, each bicycle's state is independent of and can be different from other bicycles. Your bicycle object is an instance of the class of objects known as bicycles. Bicycles of the same model are built using the same blueprint.

Software objects Possible to have many objects of the same kind that share common characteristics. Objects of the same kind can be built using the same blueprint. Software "blueprints" for objects are called classes. Definition: A class is a blueprint or prototype that defines the variables and methods common to all objects of a certain kind.

Object instantiation Remember: a blueprint of a bicycle is not really a bicycle. When you create an instance of a class, you create an object of that type. The system allocates memory for the instance variables declared by the class. You can then invoke the object's instance methods to make it do something.

Reusing Classes Classes provide the benefit of reusability. Programmers use the same class, and thus the same code, over and over again to create many objects.

Polymorphism The attribute that allows one interface to be used with a general class of actions. It is the compiler's job to select the specific action as it applies to each situation. Polymorphism helps reduce complexity by allowing the same interface to be used to specify a general class of actions.

Example Three types of stacks, one for integer values, one for strings, and one for a specific structure. You can create three sets of functions called push() and pop() , one for each type of data. The general interface is that of pushing and popping data onto and from a stack. When you push data on or pop from the stack, it is the type of the data that will determine which specific version of push() or pop(), that will be called.

Inheritance The process by which one object can acquire the properties of another object. Concept of classification Red Delicious apple ---> apple ---> fruit ---> food An object (class) need only define those qualities that make it unique. Allow classes to be defined in terms of other classes.

Example Mountain bikes, racing bikes, and tandems are all different kinds of bicycles. These are subclasses of the bicycle class. The bicycle class is the superclass of these subclasses.

More on Inheritance Each subclass inherits instance variables from the superclass. Each subclass inherits methods from the superclass. Subclasses can add their own variables and methods. Subclasses can override inherited methods. The class hierarchy can be as deep as needed. Methods and variables are inherited down through the levels. The further down in the hierarchy a class appears, the more specialized its behavior.