Classes & Objects Computer Science I Last updated 9/30/10.

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

1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
Object-Oriented Analysis and Design
CS-2135 Object Oriented Programming
1 CS1001 Lecture Overview Homework 3 Homework 3 Project/Paper Project/Paper Object Oriented Design Object Oriented Design.
OOP & JAVA. HelloWorld.java /** * The HelloWorld class is an application that * displays "Hello World!" to the standard output. */ public class HelloWorld.
Object Oriented System Development with VB .NET
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;
Fall 2007ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Object-oriented Programming Concepts
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
C++ fundamentals.
BACS 287 Basics of Object-Oriented Programming 1.
Object Oriented Programming
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Introduction to Object-oriented programming and software development Lecture 1.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
O BJECT O RIENTATION F UNDAMENTALS Prepared by: Gunjan Chhabra.
An Object-Oriented Approach to Programming Logic and Design
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.
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.
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
Computer Concepts 2014 Chapter 12 Computer Programming.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Object-Oriented Programming with Java Lecture 1: Introduction Autumn, 2007.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Learners Support Publications Object Oriented Programming.
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”
9-Dec Dec-15  INTRODUCTION.  FEATURES OF OOP.  ORGANIZATION OF DATA & FUNCTION IN OOP.  OOP’S DESIGN.
Basic Concepts of Object Orientation Object-Oriented Analysis CIM2566 Bavy LI.
C++ Introduction and Overview. Introduction It can be seen from this picture that although this depicts a central figure, it consists of separate images.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
Introduction to Object-Oriented Programming Lesson 2.
Introduction to OOP CPS235: Introduction.
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.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
COP 4331 – OOD&P Lecture 7 Object Concepts. What is an Object Programming language definition: An instance of a class Design perspective is different.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (2/2)
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.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Object Oriented Programming
Object-Oriented Programming Concepts
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
Programming Logic and Design Seventh Edition
JAVA By Waqas.
CHAPTER 5 GENERAL OOP CONCEPTS.
OOP What is problem? Solution? OOP
Table of Contents Class Objects.
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Computer Programming.
Workshop for Programming And Systems Management Teachers
Object-Oriented PHP (1)
Agenda Software development (SD) & Software development methodologies (SDM) Orthogonal views of the software OOSD Methodology Why an Object Orientation?
C++ Object Oriented 1.
Presentation transcript:

Classes & Objects Computer Science I Last updated 9/30/10

Object-Oriented Programming OOP: A programming paradigm that uses "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs Programming techniques may include … Data abstraction Encapsulation Modularity Polymorphism Inheritance

Background Object-oriented programming has roots that can be traced to the 1960s As hardware and software became increasingly complex, manageability often became a concern Researchers studied ways to maintain software quality and developed object-oriented programming in part to address common problems by strongly emphasizing discrete, reusable units of programming logic

Background OOP focuses on data rather than processes Programs are composed of self-sufficient modules ("classes") Each instance of which ("objects") contains all the information needed to manipulate its own data structure ("members") Modular programming focuses on the function of a module, rather than specifically the data MP provides for code reuse, and self-sufficient reusable units of programming logic, enabling collaboration through the use of linked modules (subroutines)

Background An object-oriented program may be viewed as a collection of interacting objects Each object is capable of … receiving messages, processing data, and sending messages to other objects

Background Each object can be viewed as an independent 'machine' with a distinct role or responsibility Actions (methods) on these objects are closely associated with the object For example … OOP data structures tend to carry their own operators around with them Or at least inherit them from a similar object or class In the conventional model, the data and operations on the data don't have a tight, formal association

What is a class? A template for an object A user-defined datatype that contains the variables, properties and methods in it Defines the abstract characteristics of a thing (object), including its characteristics and the thing's behaviors For example … The class Dog would consist of traits shared by all dogs, such as breed and fur color (characteristics), and the ability to bark and sit (behaviors)

What is a class? Provides modularity and structure in an object-oriented computer program Should typically be recognizable to a non-programmer familiar with the problem domain, meaning that the characteristics of the class should make sense in context The code should be relatively self-contained Collectively, the defined properties and methods are called members

What is a class? One can have an instance of a class; the instance is the actual object created at run-time For example … The Lassie object is an instance of the Dog class The set of attribute values for a particular object is called its state The object consists of state and the behavior that's defined in the object's classes

What is an object? A discrete bundle of functions and procedures, often relating to a particular real-world concept such as a bank account holder or hockey player Other pieces of software can access the object only by calling its functions and procedures that have been allowed to be called by outsiders Some agree that isolating objects in this way makes their software easier to manage and keep track of Others feel that software becomes more complex to maintain and document, or even to engineer from the start

OOP Features Dynamic Encapsulation (or multi-methods, in which case the state is kept separate) Polymorphism Inheritance (or delegation) Open recursion

What is a method? "The process by which an object sends data to another object or asks the other object to invoke a method.“ * Also known as interfacing For example… The object called Breeder may tell the Lassie object to sit by passing a sit message that invokes Lassie's sit() method The syntax varies between languages * Armstrong, The Quarks of Object-Oriented Development. In descending order of popularity, the "quarks" are: Inheritance, Object, Class, Encapsulation, Method, Message Passing, Polymorphism, Abstraction

Dynamic Dispatch When a method is invoked on an object, the object itself determines what code gets executed by looking up the method at run time in a table associated with the object This feature distinguishes an object from an abstract data type (or module), which has a fixed (static) implementation of the operations for all instances It is a programming methodology that gives modular component development while at the same time being very efficient

Encapsulation Conceals the functional details of a class from objects that send messages to it For example … The Dog class has a bark() method variable The code for the bark() method defines exactly how a bark happens Timmy, Lassie's friend, however, does not need to know exactly how she barks Encapsulation is achieved by specifying which classes may use the members of an object The result is that each object exposes to any class a certain interface — those members accessible to that class

Encapsulation Rationale: Prevents clients of an interface from depending on those parts of the implementation that are likely to change in the future Thereby allowing those changes to be made more easily without changes to clients For example… An interface can ensure that puppies can only be added to an object of the class Dog by code in that class Members are often specified as public, protected or private, determining whether they are available to all classes, sub-classes or only the defining class

Polymorphism Allows the programmer to treat derived class members just like their parent class's members More precisely, the ability of objects belonging to different data types to respond to calls of methods of the same name, each one according to an appropriate type-specific behavior One method, or an operator such as +, -, or *, can be abstractly applied in many different situations For example … If a Dog is commanded to speak(), this may elicit a bark() If a Pig is commanded to speak(), this may elicit an oink()

Inheritance A process in which a class inherits all the state and behavior of another class This is called child-parent or is-a relationship Subclasses are more specialized versions of a class, which inherit attributes and behaviors from their parent classes, and can introduce their own

Inheritance For example … The class Dog might have sub-classes called Collie, Chihuahua, and GoldenRetriever Lassie would be an instance (object) of the Collie subclass Assume that the Dog class defines a method called bark() and a property called furColor Each of the sub-classes will inherit these members; the programmer only needs to write the code for them once

Inheritance Each subclass can alter its inherited traits For example … The Collie subclass might specify that the default furColor for a collie is brown-and-white The Chihuahua subclass might specify that the bark() method produces a high pitch by default

Inheritance Subclasses can also add new members For example … The Chihuahua subclass could add a method called tremble() An individual Chihuahua instance would then use a high-pitched bark() from the Chihuahua subclass, which in turn inherited the usual bark() from Dog The Chihuahua object would also have the tremble() method, but Lassie would not, because she is a Collie, not a Chihuahua

Inheritance Inheritance is an "a… is a" relationship between classes, while instantiation is an "is a" relationship between an object and a class For example … a Collie is a Dog ("a… is a"), but Lassie is a Collie ("is a") Thus, the object named Lassie has the methods from both classes Collie and Dog

Open recursion A special variable (syntactically it may be a keyword), usually called this or self, that allows a method body to invoke another method body of the same object This variable is late-bound ; it allows a method defined in one class to invoke another method that is defined later, in some subclass thereof