Objects We are all familiar with the idea of an object. We are surrounded by them: cars, books, people, houses, cats, etc. Objects have attributes, e.g.

Slides:



Advertisements
Similar presentations
1 FIT1002 Computer Programming Lecture 3: Introduction to Object-Orientation.
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.
CMSC 202 Fall 2010, Advanced Section Designing with Objects.
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
© N Barnes 2004 Object-orientated Programming (OOP) Unit 4 Computing.
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
Object-Oriented PHP (1)
COMP1007 Intro to Requirements Analysis © Copyright De Montfort University 2002 All Rights Reserved COMP1007 Intro to Requirements Analysis Object Oriented.
Java is an Object-Oriented Language b In structured programming languages, methods define the structure of the programs, they are basic building blocks.
Requirements Analysis 9. 1 OO Concepts b509.ppt © Copyright De Montfort University 2000 All Rights Reserved INFO2005 Requirements Analysis Object.
1 Basic Object-Oriented Concepts  Object-Oriented Paradigm What is an Object?  What is a Class?  Constructing Objects from a class Problem Solving in.
Chapter Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Introduction to Programming. To gain a sound knowledge of programming principles To gain a sound knowledge of object- orientation To be able to critically.
Sharif University of Technology Session # 7.  Contents  Systems Analysis and Design  Planning the approach  Asking questions and collecting data 
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
State,identity and behavior of objects Sem III K.I.R.A.S.
Theories of Development. Cognitive Development Early psychologists believed that children were not capable of meaningful thought and that there actions.
CPT 140 Programming Constructs1 OBJECT ORIENTED TECHNOLOGY Terminology and Basic Concepts.
TCU CoSc Introduction to Programming (with Java) Getting to Know Java.
Java Coding 5 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. To object or not…
Object Oriented Software Development
Lecture 1 Introduction to Software Construction
1SSPD Back to Jackson Consider how JSP views programming- –Describe structure I/O datastreams –Combine to produce a program structure –List operations.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
Object Oriented Concepts & Principles Ingrid Kirschning & Gerardo Ayala.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Java Coding 5 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. To object or not…
Introduction to Objects Adapted from “TEN STEPS TO OBJECT-SPEAK” a CPT Tech Talk by Joy Starks September 17, 1999.
CS 350 – Software Design The Object Paradigm – Chapter 1 If you were tasked to write code to access a description of shapes that were stored in a database.
I am ready to test!________ I am ready to test!________
Downloaded From:  Objective of this course is to make students familiar with the concepts of object-oriented programming  Concepts.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
1 Functions Lecfture Abstraction abstraction is the process of ignoring minutiae and focusing on the big picture in modern life, we are constantly.
Object Oriented Programming Principles Lecturer: Kalamullah Ramli Electrical Engineering Dept. University of Indonesia Session-3.
Behavioral Modeling Chapter 8.
SNPL1 Woochang Lim What (Variable) + How (Function) = Object Objects are the physical and conceptual things we find in the universe around us. Object-Oriented.
Object-Oriented Design Simple Program Design Third Edition A Step-by-Step Approach 11.
CSC241 Object-Oriented Programming (OOP) Lecture No. 1.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
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.
Introduction to Object-oriented Programming Java API.
Information Integration By Neel Bavishi. Mediator Introduction A mediator supports a virtual view or collection of views that integrates several sources.
Object Orientation Concepts, Terminology and a Story. © Allan C. Milne School of Engineering, Computing & Applied Mathematics University of Abertay v
1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd.
1 OO Analysis & Design - Introduction to main ideas in OO Analysis & design - Practical experience in applying ideas.
Designing Classes CS239 – Jan 26, Key points from yesterday’s lab  Enumerated types are abstract data types that define a set of values.  They.
Salman Marvasti Sharif University of Technology Winter 2015.
OOP (Object Oriented Programming) Lecture 1. Why a new paradigm is needed? Complexity Five attributes of complex systems –Frequently, complexity takes.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
Object-Oriented Principals Dwight Deugo Nesa Matic
The Last Lecture CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
Programming. To gain a sound knowledge of programming principles To gain a sound knowledge of object- orientation To be able to critically assess the.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
Object-Oriented Paradigm (OOP) Course Code: SE 101 Lecture No. 1.
Object Oriented Paradigm OOP’s. Problems with Structured Programming As programs grow ever larger and more complex, even the structured programming approach.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Defining Classes. Why is Java designed this way? Improving our class Creating our own class Using our class Implementing our class.
Object-Oriented Programming (OOP) Lecture No. 1. Course Objective ► Objective of this course is to make students familiar with the concepts of object-oriented.
9.1 CLASS (STATIC) VARIABLES AND METHODS Defining classes is only one aspect of object-oriented programming. The real power of object-oriented programming.
IB Computer Science Content developed by Dartford Grammar School Computer Science Department UML.
WEEK 1 1 What is a Computer Program? An algorithm that can be executed on a computer is a program. A program usually contains several algorithms.
UML Class & Object Diagram I
OOP - Object Oriented Programming
Object Oriented Concepts -I
OBJECT ORIENTED PROGRAMMING overview
Subroutines Idea: useful code can be saved and re-used, with different data values Example: Our function to find the largest element of an array might.
Workshop for Programming And Systems Management Teachers
Introduction to Object-Oriented Software Development
Lecture 1 Introduction to Software Construction
Presentation transcript:

Objects We are all familiar with the idea of an object. We are surrounded by them: cars, books, people, houses, cats, etc. Objects have attributes, e.g. colour, size, age, name. Objects also have behaviour. They can do things, e.g. grow, breathe, run, stop.

Attributes and Behaviour Car Cat AttributesBehaviour Registration number Make Model Year Colour Start Stop Turn Accelerate Name Breed Colour Age Weight Registration number Sleep Eat Purr Climb Scratch

Abstraction and Models In a program, we choose the attributes and behaviours that are relevant to the problem we are trying to solve. This process of selecting some aspects of the objects and ignoring the irrelevant ones is called abstraction. We create a model that is a simplification of the real situation, strictly relevant to the problem to be solved.

Simulation When we write a program, we are often simulating something that happens in real life. The models we create in our program correspond to real life objects, e.g. customers, invoices, receipts. Sometimes the simulation is more explicit, e.g. a program that models a set of traffic lights to work out the optimum times for changing them to keep the traffic flowing smoothly. The object-oriented style (or paradigm) of programming is very well suited to simulations.

Object-Oriented Programs The object-oriented programming paradigm uses objects to model a situation. A program can be written in a non-object-oriented way, but the object-oriented style is increasingly popular for three main reasons: programs are becoming more and more complex, and the OO style handles this best the OO style makes it easy to re-use existing programs or parts of them the OO style makes programs much easier to maintain.

Classification We classify objects into groups according to their common attributes and behaviour. Let's say we want to classify objects into balls and not-balls. What are the common attributes and behaviour of something we would classify as a ball? How would you recognise a ball if you saw one?

Classes In a computer program, we use classes to describe similar objects. A class is a description of what an object would look like if we had one. It is based on common attributes and behaviour of objects. Radio currentStation volume turnOn turnOff changeStation increaseVolume decreaseVolume

Instances of Classes A class is a template that describes what an object would look like if we had one. We instantiate the class to create an instance, i.e. an object of that class. The object is an instance of the class. We can have many instances of the same class. Each object has the same attributes and the same behaviour. However, the values of the attributes might be different.

Identity We can have several different objects that have the same attributes and behaviour (even the same state) but are still different objects. An object has identity. We can give it a name to distinguish it from the others (e.g. ball1, ball2).

State of an Object The state of a particular object is the values of its attributes at any particular moment. For example, a cat might have the following state: Name: Max Breed: American Shorthair Colour: Black, brown & white Age: 3 years, 4 months, 8 days Weight: 5.1 kg Registration number: Some of these attributes change constantly. Others stay the same for long periods or forever.

A Person Class Let's imagine we need a model of a person to solve some problem. For the purposes of this problem, it is enough to let a person have just a name and an age. Person name age display getAge getName setAge setName

An Object Hides Its Attributes name age If you want to find out the value of an attribute of an object, you have to ask the object to tell you.

Message Passing To get an object to do something it knows how to do, you have to send it a message requesting that behaviour. name age getName "Jack" bestFriend

Sending a Message to an Object There are 3 parts in a message sent to an object: the name of the object that is the receiver the action that the receiver is requested to take in parentheses, any extra information the receiver needs to know. In Java, the syntax for asking the person called bestFriend to tell you its name would be: –bestFriend.getName();

Passing Information in a Message When an object needs to know some extra information in order to do what you want, you can pass it that information with the message. If you decide that Jack is no longer your best friend but Sally now is, and want the object bestFriend to change its name to "Sally", you need to send it a message that tells it to change its name, and also what to change it to. The extra information is called arguments or parameters. –bestFriend.setName("Sally");