Chapter 10 Introduction to Objects and Classess 1.

Slides:



Advertisements
Similar presentations
1 Classes and Objects in Java Basics of Classes in Java.
Advertisements

Object-Oriented Programming Basics Prof. Ankur Teredesai, Computer Science Department, RIT.
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
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.
6-1 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer problem-solving process and relate it to Polya’s.
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Classes & Objects Computer Science I Last updated 9/30/10.
Tutorial 6 February 4th/5th, 2015
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Fall 2007ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
1 Basic Object Oriented Concepts Overview l What is Object-Orientation about? l What is an Object? l What is a Class? l Constructing Objects from Classes.
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 7 Object-Oriented Programming.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
State,identity and behavior of objects Sem III K.I.R.A.S.
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
1 Chapter 14 Object-Oriented Software Development.
Introduction to Object-oriented programming and software development Lecture 1.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
OBJECT-ORIENTEDNESS KCDCC. WHAT IS OBJECT-ORIENTEDNESS? KCDCC model system as a collection of interacting objects O-O Modelling O-O Programming similar.
School of Computer Science & Information Technology G6DICP - Lecture 22 The Theory of Object Oriented Programming.
Lecture # 5 Methods and Classes. What is a Method 2 A method is a set of code which is referred to by name and can be called (invoked) at any point in.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Object-Oriented Programming (OOP) CSC-2071 (3+1=4 Credits) Lecture No. 1 MBY.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
1 Classes and Objects in C++ 2 Introduction Java is a true OO language and therefore the underlying structure of all Java programs is classes. Anything.
1 Classes and Objects in Java Basics of Classes in Java.
Design.ppt1 Top-down designs: 1. Define the Problem IPO 2. Identify tasks, Modularize 3. Use structure chart 4. Pseudocode for Mainline 5. Construct pseudocode.
 Computer Science 1MD3 Introduction to Programming Michael Liut Ming Quan Fu Brandon.
BCS 2143 Object Oriented Design Using UML. Objectives Objects Interactions Finding Classes Relationship Between Classes Attribute and Operation Class.
What is Object-Oriented?  Organization of software as a collection of discreet objects that incorporate both data structure and behavior.
Object-Oriented Programming •Object-Oriented Programming (OOP) allows you to create your program based upon modeling objects.  Your program’s properties.
Learners Support Publications Object Oriented Programming.
Object Oriented Programming A new way of thinking.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
1 Overview of Object-Oriented Software Design and Java Programming Putting the Pieces Together!
Basic Concepts of Object Orientation Object-Oriented Analysis CIM2566 Bavy LI.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 12 Object-Oriented Programming Starting Out with Games & Graphics.
OOP (Object Oriented Programming) Lecture 1. Why a new paradigm is needed? Complexity Five attributes of complex systems –Frequently, complexity takes.
1 Software Engineering Lecture 15 Object Oriented Software Design in Java.
CS 139 Objects Based on a lecture by Dr. Farzana Rahman Assistant Professor Department of Computer Science.
Chapter 11 An introduction to object-oriented design.
Classes and Objects. How can one design a program?  Top-down structured design: uses algorithmic decomposition where each module denotes a major step.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
Introduction to Object Oriented Programming Lecture-3.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
INTRODUCTION Java is a true OO language the underlying structure of all Java programs is classes. Everything must be encapsulated in a class that defines.
 The Object Oriented concepts was evolved for solving complex problems. Object- oriented software development started in the 1980s. Object-oriented design.
Object Oriented Programming
Chapter 7 Object-Oriented Programming
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
Object-Oriented Programming Basics
Classes and OOP.
Object-Oriented Analysis and Design
Classes and Objects in Java
Classes and Objects in Java
Classes and Objects in Java
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Anatomy of a Class & Method
Object-oriented Design in Processing
Object-oriented Design in Processing
Workshop for Programming And Systems Management Teachers
Object-oriented Design in Processing
Handout-2(a) Basic Object Oriented Concepts
Agenda Software development (SD) & Software development methodologies (SDM) Orthogonal views of the software OOSD Methodology Why an Object Orientation?
CS 4310: Software Engineering
Object-oriented Design in Processing
Presentation transcript:

Chapter 10 Introduction to Objects and Classess 1

How can one design a program?  Top-down structured design : uses algorithmic decomposition where each module denotes a major step in some overall process  Object-oriented design : divides the problem into a set of objects that interacts to solve the problem. Your program ’ s properties and behaviors are modelled based upon real objects like cars, books, houses, etc. 2

Why OOD?  Software is complex (too many people is doing too many things – the mess is inevitable )  One of the main goals in programming is to avoid the redundancy and objects can help to do this ( inheritance )  Objects can help increase modularity through data hiding ( encapsulation ) 3

OK, but what is object ?  An object is a thing, either tangible or intangible.  An object-oriented program consists of many objects.  An object is composed of identity, state (attributes, data, and their current values) and behavior (operations). 4

Identity, State, Behavior  Identity is the property of an object that distinguishes it from all other objects.  The failure to recognize the difference between the name of the object and the object itself is the source of many errors in object- oriented (OO) programming. 5

Identity, State, Behavior  The state of an object encompasses all of the (static) properties of the object plus the current (dynamic) values of each of these properties  A property is an inherent or distinctive characteristic, trait, quality, or feature that contribute to making an object uniquely that object  We will use the word attribute, or data member, to refer to the state of an object 6

Examples of State  Properties  Elevators travel up or down  Vending machines accept coins  Clocks indicate the current time  Values  Current floor  Number of coins deposited  The number of minutes since the last hour 7

Identity, State, Behavior  Behavior is how an object acts and reacts, in terms of state changes and interactions with other objects.  An operation is some action that one object performs upon another in order to elicit a reaction.  We will use the word method to describe object behavior in java.  Invoking a method causes the behavior to take place. 8

Classes  Classes are the definitions (or blueprints) used to create objects. I’d say: descriptions of objects.  To make a car the manufacturer must first have a design from which to build the first car. Then, once all the problems are worked out, the design is used to build all the cars of that model. 9

Objects  An object is an instance of a class.  If we have a class definition called Car, then we can think of Audi, BMW, and Corvette as each being an instance (object) of the class Car, i.e., they are each a type of car. 10

Object example 11 Audi 6BMW Z3Corvette Notice that all objects are of the same type. All objects are cars! Car

Classes and Objects  An object is an instance of exactly one class!!!  Corvette can not be an instance of a car class and an instance of a plane class at the same time.  An instance of a class, an object, belongs to that particular class.  A Corvette is a car  Corvette belongs to the class Car. 12

Classes  Once a class is defined you can create as many instances of the class (objects from the class) as you would like.  Once a blue print is completed for the 2003 Porsche 911, Porsche will use an assembly line to build as many instances of the 2003 Porsche 911 as they wish. 13

Class car and objects- graphically 14 Audi 6BMW Z3Corvette Car This line shows an instance-of relationship.

Defining a class  Properties are variables which describe the essential characteristics of an object. Properties of a car: color, model, make, how many doors, transmission type, direction of movement, etc.  Behaviors are methods that describe how the object behaves and how the properties may be modified. Behavior of a car: braking, changing gears, opening doors, moving forwards or backwards, etc. 15

Classes  A class is a collection of fields (data) and methods (procedure or function) that operate on that data. 16 Circle centre radius circumference() area()

Adding Fields: Class Circle with fields  Add fields  The fields (data) are also called the varaibles. 17 public class Circle { public double x, y; // centre coordinate public double r; // radius of the circle }

Data Abstraction  Declare the Circle class, have created a new data type – Data Abstraction  Can define variables (objects) of that type: Circle aCircle; aCircle = new Circle(); OR Circle bCircle = new Circle(); 18