Object Oriented Programming The object concept. Alan Kay—Smalltalk—5 basic characteristics of OOP 1.Everything is an object. An object is a fancy variable-it.

Slides:



Advertisements
Similar presentations
Final and Abstract Classes
Advertisements

General OO Concepts Objectives For Today: Discuss the benefits of OO Programming Inheritance and Aggregation Abstract Classes Encapsulation Introduce Visual.
Object-Oriented Programming Python. OO Paradigm - Review Three Characteristics of OO Languages –Inheritance It isn’t necessary to build every class from.
ITEC200 – Week03 Inheritance and Class Hierarchies.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Object-oriented Programming Concepts
Chapter 10 Classes Continued
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C++ fundamentals.
1 Chapter 8 Objects and Classes. 2 Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections,
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
CONCEPTS OF OBJECT ORIENTED PROGRAMMING. Topics To Be Discussed………………………. Objects Classes Data Abstraction and Encapsulation Inheritance Polymorphism.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
Objected Oriented Programming & Design JAVA Shishir Gupta (704) (704)
Inheritance - Polymorphism ITI 1121 Nour El Kadri.
Object-Oriented Programming. An object is anything that can be represented by data in a computer’s memory and manipulated by a computer program.
Chapter 12 Support for Object oriented Programming.
BCS 2143 Object Oriented Design Using UML. Objectives Objects Interactions Finding Classes Relationship Between Classes Attribute and Operation Class.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Salman Marvasti Sharif University of Technology Winter 2015.
Object Oriented Programming
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
CITA 342 Section 1 Object Oriented Programming (OOP)
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Object-Oriented Design
Sections Inheritance and Abstract Classes
Java Primer 1: Types, Classes and Operators
Table of Contents Class Objects.
Java Review Hello..This ppt is to give you an introduction about java and why it is soo special The segments all discussed here are the crucial parts of.
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Section 11.1 Class Variables and Methods
Can perform actions and provide communication
Chapter 3 Introduction to Classes, Objects Methods and Strings
Can perform actions and provide communication
Week 6 Object-Oriented Programming (2): Polymorphism
Object Oriented Programming
Can perform actions and provide communication
Object Oriented Programming in java
Final and Abstract Classes
Object-Oriented Programming
Lecture 10 Concepts of Programming Languages
Presentation transcript:

Object Oriented Programming The object concept

Alan Kay—Smalltalk—5 basic characteristics of OOP 1.Everything is an object. An object is a fancy variable-it stores data, but it is also asked to perform operations on itself by making requests. 2.A program is a bunch of objects telling each other what to do by sending messages. A message is a request to call a function that belongs to a particular object.

Alan Kay—Smalltalk—5 basic characteristics of OOP 3. Each object has its own memory made up of other objects. Also, a new kind of object can be created by making up a package containing existing objects. Complexity is built up while at the same time, objects have simplicity. 4. Every object has a type. In Java-speak, each object is an”instance of a class”, where class = type. Important distinguishing characteristic of a class: what messages can be sent to it?

Alan Kay—Smalltalk—5 basic characteristics of OOP 5. All objects of a particular type can receive the same messages. If an object of type circle is also an object of type shape, a circle is guaranteed to receive shape messages. Can write code to talk to shapes and automatically handle anything that fits the description of a shape. This “substitutability” is a powerful concept of OOP.

Six Ideas in Object Oriented Programming zClasses zInstances zEncapsulation z Overloading z Inheritance z Polymorphism

Six Ideas in Object Oriented Programming z(1) Classes: the fundamental structure of every Java program, containing data fields and mechanisms to manipulate that data; classes can provide blueprints to construct software objects z“class” is a keyword that precedes the class name zClass is a user-defined type, and instances of such a type are called objects.

Six Ideas in Object Oriented Programming (1-- Classes) zClasses consist of any number of two basic kinds of class members, called fields: variables and methods.

Six Ideas in Object Oriented Programming (1 -- Classes) zThe left brace immediately following the class name begins the definition of the class zA matching right brace is needed to end the class definition zex:class binary{ }

Six Ideas in Object Oriented Programming (1 -- Classes) zWrapper classes: wraps a single primitive value inside an object for structures that work with objects instead of primitive data types (ex:Vectors, which will be discussed later) or for static methods related to the corresponding primitive data type.

Six Ideas in Object Oriented Programming (1 -- Classes) zAll wrapper classes have names that are closely related to their corresponding basic types, but staring with a capital letter zsyntax: WrapperName varName [=new WrapperName (basicType)]; zWrapperName=Character,Double or Integer zbasicType=char,double or int

Six Ideas in Object Oriented Programming z[2] Instances: objects that were constructed according to the class blueprints and that exist in the memory of the computer. zOne class can be used to instantiate a number of objects.

Six Ideas in Object Oriented Programming [2-- Instance] zInstance emphasizes an object’s relationship to its class zex: suppose a Car class is used to create the objects hotrod, racer, and junker; all these objects have their fields defined in the Car declaration; hotrod, racer and junker are “instances of Car”.

Six Ideas in Object Oriented Programming zEncapsulation: allowing or disallowing access to the data and mechanisms that a class provides zIt is the ability to hide internal detail while providing a public interface to a user- defined type; Java uses the class declarations in conjunction with the access keywords “private” and “public” to provide encapsulation.

Six Ideas in Object Oriented Programming [3-- Encapsulation] zpublic-- a field, method or class that is accessible to every class. zprotected-- a field, method or class that is accessible to the class itself, subclasses, and all classes in the same package or directory.

Six Ideas in Object Oriented Programming [3-- Encapsulation] zfriendly-- a field, method or class accessible to the class itself and to all classes in the same package or directory. A field or method is declared friendly if other modifiers are absent. zprivate-- a field or method accessible only to the class in which it is defined. A class cannot be declared private as a whole. zEx--tester,tester2

Six Ideas in Object Oriented Programming z(4) Overloading--providing multiple definitions for certain mechanisms,allowing them to adjust to different situations. z“+” is overloaded--used for numeric addition as well as String concatenation. zEx--Overloading order (identical arguments for print method, but different order)

Six Ideas in Object Oriented Programming z(5)Inheritance--a mechanism to improve the relationships between classes and their corresponding objects. zClass or classes inherited from are called superclasses, or ancestors. zInheriting classes are called subclasses, or descendants zInheritance is indicated by keyword “extends”. Ex:Rings2

Six Ideas in Object Oriented Programming z(6)Polymorphism--The ability to deal with multiple related classes based on a common feature, based on a common feature, giving an entire class hierarchy the ability to adjust to an appropriate situation. zThe compiler selects at runtime those methods and objects from an appropriate inheritance hierarchy.

Six Ideas in Object Oriented Programming (6) zEx-ShapeTester: Circle,Square,Rectangle,Shape. zShape=superclass, zthree fields=name,area,perimeter ztwo methods=constructor and display method zCircle,Rectangle,Square=subclasses (descendants)