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;

Slides:



Advertisements
Similar presentations
By Waqas Over the many years the people have studied software-development approaches to figure out which approaches are quickest, cheapest, most.
Advertisements

Methods Java 5.1 A quick overview of methods
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.
1 Object-Oriented Programming Concepts. 2 Recap from last lecture Variables and types –int count Assignments –count = 55 Arithmetic expressions –result.
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
OBJECT-ORIENTED PROGRAMMING CONCEPTS (Review). What is an Object? What is an Object? Objects have states and behaviors. Example: A dog has states - color,
Object-Oriented Analysis and Design
Classes and Objects in Java. What Is an Object?. An object is a software bundle of related state and behavior. Software objects are often used to model.
EEC-681/781 Distributed Computing Systems Java Tutorial Wenbing Zhao Cleveland State University
Object-Oriented Programming Chapter Two. Java Buzz Words Simple Architecture neutral Object oriented Portable Distributed High performance Interpreted.
Introduction to Alice Basics : What is Alice? Object Oriented Definitions What Does it Look Like? Where Can I Use it?
Object-oriented Programming Concepts
1 Writing a Good Program 5. Objects and Classes in C++
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
Object Oriented Paradigm Programming Paradigms En Mohd Norafizal A.Aziz.
CSC241: Object Oriented Programming
MIT AITI 2003 Lecture 7 Class and Object - Part I.
1 Pertemuan 6 Object Oriented Programming Matakuliah: T0053/Web Programming Tahun: 2006 Versi: 2.
Lecture 1 Introduction to Java MIT- AITI 2004 What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word.
Object Oriented Software Development
Object-Oriented Programming Concepts
BCS 2143 Introduction to Object Oriented and Software Development.
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.
Object Oriented Programming Concepts Fatih University Ceng-104-A Introduction to Object Oriented Programming Harun Reşit Zafer This is a slide version.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
CS1201: Programming Language 2 Classes and objects By: Nouf Aljaffan Edited by : Nouf Almunyif.
Object Oriented Programming Concepts. Object ► An object is a software bundle of related state and behavior. ► Software objects are often used to model.
Object-Oriented Programming with Java Lecture 1: Introduction Autumn, 2007.
CSC 131 Fall 2006 Lecture # 6 Object-Oriented Concepts.
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.
Salman Marvasti Sharif University of Technology Winter 2015.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
JAVA Programming (Session 4) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Chapter 4 Basic Object-Oriented Concepts. Chapter 4 Objectives Class vs. Object Attributes of a class Object relationships Class Methods (Operations)
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
By : Robert Apeldorn. What is OOP?  Object-oriented programming is a programming paradigm that uses “objects” to design applications and computer programs.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 1 Introduction to Object-Oriented Programming and.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Object and Classes อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 3.
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.
Object Oriented Programming in Java Habib Rostami Lecture 2.
Systems Analysis & Programming 10.1 Systems Development 10.2 Programming: A Five-Step Procedure Generations of Programming Languages 10.4 Programming.
Introduction to Object-oriented Programming
Object-Oriented Programming
What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related.
Object-Oriented Programming Concepts
JAVA By Waqas.
Objects as a programming concept
University of Central Florida COP 3330 Object Oriented Programming
Objects as a programming concept
Object Oriented Concepts -I
University of Central Florida COP 3330 Object Oriented Programming
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Unit-2 Objects and Classes
Advanced Programming Behnam Hatami Fall 2017.
Introducing Java.
Object-Oriented Programming
Presentation transcript:

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; i.e dogs have state (name, color, breed, hungry) and behavior (barking, fetching, and wagging tail). Bicycles have state (current gear, current pedal cadence, two wheels, number of gears) and behavior (braking, accelerating, slowing down, changing gears). Software objects are modeled after real-world objects in that they too have state and behavior. A software object maintains its state in one or more variables. A variable is an item of data named by an identifier. A software object implements its behavior with methods. –A method is a function (subroutine) associated with an object. Definition: An object is a software bundle of variables and related methods.

Object? Real-world dog can be represented as software objects in an animation program! or a real-world bicycle as a software object in the program that controls an electronic exercise bike! You can also use software objects to model abstract concepts. For example, an event is a common object used in GUI window systems to represent the action of a user pressing a mouse button or a key on the keyboard.

Object? A software object: Everything that the software object knows (state) and can do (behavior) is expressed by the variables and the methods within that object. An object for a bicycle would have variables (bicycle states) like: its speed (i.e.10 mph), its current gear (i.e 5th gear). These variables are formally known as instance variables because they contain the state for a particular bicycle object in object-oriented terminology, a particular object is called an instance.

Object? A bicycle modeled as a software object: In addition to its variables, the software bicycle would also have methods to brake, change the pedal cadence, and change gears. These methods are formally known as instance methods because they inspect or change the state of a particular bicycle instance.

Object? Packaging an object's variables within the protective custody of its methods is called encapsulation. encapsulation is the ideal that designers of object-oriented systems aimed for. However, for practical reasons, an object may wish to expose some of its variables or hide some of its methods. In the Java programming language, an object can specify one of four access levels for each of its variables and methods.

Object? Encapsulating provides two primary benefits : Modularity: –The source code for an object can be written and maintained independently of the source code for other objects. – an object can be easily passed around in the system. You can give your bicycle to someone else, and it will still work. Information hiding: –An object has a public interface that other objects can use to communicate with it. –The object can maintain private information and methods that can be changed at any time without affecting the other objects that depend on it. (You don't need to understand the gear mechanism on your bike to use it. )

What is a Message? An object usually appears as a component of a larger program or application that contains many other objects. Through the interaction of these objects, programmers achieve higher-order functionality and more complex behavior. (bicycle and you!) Software objects interact by sending messages to each other. When object A wants object B to perform one of B's methods, object A sends a message to object B.

What is a Massage? the receiving object may need more information so that it knows exactly what to do (changing gears on your bicycle). This information is passed along with the message as parameters.

What is a Massage? Messages provide two important benefits: An object's behavior is expressed through its methods, so (aside from direct variable access) message passing supports all possible interactions between objects. Objects don't need to be in the same process or even on the same machine to send and receive messages back and forth to each other.

What Is a Class? We often have many objects of the same kind (Bicycles). In object-oriented terminology, your bicycle object is an instance of the class of objects known as bicycles. Bicycles have some state (current gear, current cadence, two wheels) and behavior (change gears, brake) in common. However, each bicycle's state is independent of and can be different from that of other bicycles. In an object-oriented software, we may have many objects of the same kind that share characteristics: rectangles, employee records, video clips, and so on. We can create a blueprint for similar objects. A software blueprint for objects is called a class. Definition: A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind.

What is a class? The class for our bicycle example would declare the instance variables necessary to contain the current gear, the current cadence, and so on, for each bicycle object. The class would also declare and provide implementations for the instance methods that allow the rider to change gears, brake, and change the pedaling cadence, as shown in the next figure.

What is a class? You can create bicycle objects from the class. By creating an instance, the system allocates memory for the object and all its instance variables.

What is a class? In addition to instance variables, classes can define class variables. A class variable contains information that is shared by all instances of the class. For example, suppose that all bicycles had the same number of gears. In this case, you can define a class variable that contains the number of gears. All instances share this variable. A class can also declare class method. You can invoke a class method directly from the class, whereas you must invoke instance methods on a particular instance.

What is a class? …

Objects vs. Classes They are very similar; however, the difference between classes and objects is often the source of some confusion. it's a little difficult to differentiate classes and objects in software. This is partially because the term "object" is sometimes used to refer to both classes and instances. A class represents a blueprint of an object rather than an object itself. An object exist and you can use it, but a class is just a blueprint.