S.Ducasse Stéphane Ducasse 1 Object-Oriented Programming.

Slides:



Advertisements
Similar presentations
4. Object-Oriented Programming Procedural programming Structs and objects Object-oriented programming Concepts and terminology Related keywords.
Advertisements

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.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
Stéphane Ducasse2.1 OOP? What is OOP? Why? OOP in a nutshell.
Object-Oriented Analysis and Design
Chapter 1 Object-Oriented System Development
Introduction To System Analysis and Design
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Object Oriented System Development with VB .NET
Stéphane Ducasse6.1 Essential Concepts Why OO? What is OO? What are the benefits? What are the KEY concepts? Basis for all the lectures.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Object-oriented concepts.
Object-oriented Programming Concepts
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Copyright 2004 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Second Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix.
Software Lifecycle A series of steps through which a software product progresses Lifetimes vary from days to months to years Consists of –people –overall.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
BACS 287 Basics of Object-Oriented Programming 1.
CPT 140 Programming Constructs1 OBJECT ORIENTED TECHNOLOGY Terminology and Basic Concepts.
Introduction To System Analysis and design
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
BCS 2143 Introduction to Object Oriented and Software Development.
An Object-Oriented Approach to Programming Logic and Design
Sadegh Aliakbary Sharif University of Technology Fall 2011.
CHAPTER ONE Problem Solving and the Object- Oriented Paradigm.
Introduction to Objects Adapted from “TEN STEPS TO OBJECT-SPEAK” a CPT Tech Talk by Joy Starks September 17, 1999.
© S. Demeyer, S. Ducasse, O. Nierstrasz Intro.1 1. Introduction Goals Why Reengineering ?  Lehman's Laws  Object-Oriented Legacy Typical Problems  common.
Copyright 2001 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix A Object-Oriented.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Introduction To System Analysis and Design
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
1 Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill Chapter 2: Object Basics Object-Oriented Systems Development Using the Unified Modeling.
S.Ducasse Stéphane Ducasse 1 Design Heuristics.
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 Programming. An object is anything that can be represented by data in a computer’s memory and manipulated by a computer program.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
Basic OOP Concepts and Terms. In this class, we will cover: Objects and examples of different object types Classes and how they relate to objects Object.
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.
ITEC 3220A Using and Designing Database Systems Instructor: Prof Z. Yang Course Website: 3220a.htm
Design Model Lecture p6 T120B pavasario sem.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
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”
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
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.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
S.Ducasse Stéphane Ducasse 1 Essential OO Concepts Stéphane Ducasse.
OOP (Object Oriented Programming) Lecture 1. Why a new paradigm is needed? Complexity Five attributes of complex systems –Frequently, complexity takes.
Next Back MAP MAP F-1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Appendix A Object-Oriented Analysis and Design A.1.
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)
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
Sadegh Aliakbary Sharif University of Technology Fall 2010.
16 April 2011 Alan, Edison, etc, Saturday.. Knowledge, Planning and Robotics 1.Knowledge 2.Types of knowledge 3.Representation of knowledge 4.Planning.
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.
Object Oriented Programming
The Movement To Objects
Advanced Programming Behnam Hatami Fall 2017.
Workshop for Programming And Systems Management Teachers
Handout-2(b) Dr. R. Z. Khan AMU. Aligarh (INDIA).
What Is Good Software(Program)?
Object-Oriented PHP (1)
Presentation transcript:

S.Ducasse Stéphane Ducasse 1 Object-Oriented Programming

S.Ducasse License: CC-Attribution-ShareAlike

S.Ducasse 3 Outline Context: Software MUST evolve OOP Modeling Objects Classes Inheritance

S.Ducasse 4 Continuous Development 17.4% Corrective (fixing reported errors) 18.2% Adaptive (new platforms or OS) 60.3% Perfective (new functionality) The bulk of the maintenance cost is due to new functionality  even with better requirements, it is hard to predict new functions data from [Lien78a] 4.1% Other Relative Maintenance Effort Between 50% and 75% of global effort is spent on “maintenance” !

S.Ducasse 5 Lehman's Laws A classic study by Lehman and Belady [Lehm85a] identified several “laws” of system change. Continuing change A program that is used in a real-world environment must change, or become progressively less useful in that environment. Increasing complexity As a program evolves, it becomes more complex, and extra resources are needed to preserve and simplify its structure. Those laws are still applicable to brand new object-oriented applications 5

S.Ducasse 6 Software is living… Early decisions may have been good at that time But the context changes Customers change Technology changes People change Successful software MUST evolve

S.Ducasse 7 The Old Way Computer system consists of data and programs. Programs manipulate data. Programs organized by functional decomposition dataflow modules

S.Ducasse 8 OOP Computer system consists of a set of objects. Objects are responsible for knowing and doing certain things. Objects collaborate to carry out their responsibilities. Programs organized by classes, inheritance hierarchies and subsystems

S.Ducasse 9 Accidental vs. Essential Complexity Assembly is perfect to write 8k programs! But we need abstraction tools to model the complexity of the world Object-oriented programming in only one way Reactive languages, Relational languages, Logic Languages, … are others OOP helps reducing the accidental complexity not the essential Bad OO programs are also difficult to understand, extend, and maintain

S.Ducasse 10 Outline Context: Software MUST evolve OOP Modeling Objects Classes Inheritance

S.Ducasse 11 What is an object, anyway? Programming language view An object-oriented system is characterized by data abstraction inheritance polymorphism by late-binding of procedure calls

S.Ducasse 12 Modeling All phases of software life-cycle are modeling analysis - modeling of problem design - modeling of solution implementation - making model run on a computer maintenance - fixing/extending your model

S.Ducasse 13 Modeling Claim: people model the world with "objects" objects and classes relationships between objects relationships between classes Advantages of object-oriented software development more natural - matches the way people think single notation - makes it easy to move between software phases

S.Ducasse 14 Objects and Relationships John is Mary's father. Mary is John's daughter. Bob is Mary's dog. Mary is Bob's owner. Ann is John's employer. John is Ann's employee.

S.Ducasse 15 Objects and Attributes John's name is "John Patrick O'Brian". John's age is 27. John's address is 987 N. Oak St, Champaign IL What about John's employer? John's wife? What is an attribute, and what is a relationship?

S.Ducasse 16 Objects and Behavior John goes on a trip. John makes reservations. John buys tickets. John travels by airplane. John checks into hotel.

S.Ducasse 17 What is really an object? Anything we can talk about can be an object, including relationships ("the husband of the first party", "first-born son"). What are we trying to model? “Models should be as simple as possible, but no simpler”. Models are dictated by domains

S.Ducasse 18 Some Examples Things that we can manipulate or see: Book, BD Things that we can conceptually see: Process, Mortgage, InsuranceContract, Socket, Rôles: Mother, Teacher, Drivers, Algorithms Events and transactions Library elements: Color, Window, Text, Dictionary, Date, Boolean.... Organizations, processes

S.Ducasse 19 RoadMap Context: Software MUST evolve OOP Modeling Objects Classes Inheritance

S.Ducasse 20 State + Behavior + Identity

S.Ducasse 21 State + Behavior + Identity State: Objects it contains or refers to Ex: point location Behavior: an object understands a given set of messages Identity: an object can be the same (of the same class) than another one but it has still a different identity (location in memory)

S.Ducasse 22 Object Data Messages Methods

S.Ducasse 23 What: Messages – Specify what behavior objects are to perform – Details of how are left up to the receiver – State information only accessed via messages How: Methods – Specify how operation is to be performed – Must have access to (contain or be passed) data – Need detailed knowledge of data – Can manipulate data directly Behavior + State + Control Data Methods Messages

S.Ducasse 24 Equality and Identity I want to eat the pizza that you are eating Equality: I want to eat the “same” kind of pizza Identity: I eat your pizza

S.Ducasse 25 Encapsulation

S.Ducasse 26 Encapsulation Object protects its data We cannot access private data Object protects its implementation choice Clients use a public interface Object can change its implementation

S.Ducasse 27 Object Summary Objects have an identity have attributes have behavior have relationships with other objects Objects protect their data offer services, protect their implementation

S.Ducasse 28 Roadmap Context: Software MUST evolve OOP Modeling Objects Classes Inheritance

S.Ducasse 29 Classification We naturally put objects into classes that have similar characteristics. John is a man. Mary is a woman. Bob is a dog. All women are people. All people are mammals.

S.Ducasse 30 A Class generates Instances

S.Ducasse 31 Classes: Factory of Objects Reuse behavior => Factor into class Class: “Factory” object for creating new objects of the same kind Template for objects that share common characteristics

S.Ducasse 32 Class: Mold of Objects **Describe** state but not effective values of all the instances of the class – Position, width and length for rectangles **Define** behavior of all instances of the class Rectangle>>area ^ width * height

S.Ducasse 33 Instances A particular occurrence of an object defined by a class Each instance has its own value for the instance variables All instances of a class share the same methods

S.Ducasse 34 An example Let’s control robots....

S.Ducasse 35 Instances Creation Asking a class to create an instance The Bot factory creates a new robot

S.Ducasse 36 Instance Interaction We send messages to individual robots too

S.Ducasse 37 Instances are autonomous...

S.Ducasse 38 Instances vs. Classes The class Bot does not understand go: 100 The class Bot understand new to create new robots aBot does not understand new aBot understands robot messages such as turn:, go:, jump:, turnLeft:, color, lookLikeTriangle

S.Ducasse 39 Roadmap Context: Software MUST evolve OOP Modeling Objects Classes Inheritance

S.Ducasse 40 How to Share Specification? Do not want to rewrite everything! Often times want small changes Man are a specialization of People OOP language offers inheritance to reuse or specialize classes Class hierarchies for sharing of definitions Each class defines or refines the definition of its ancestors

S.Ducasse 41 Inheritance New classes Can add state and behavior (ColoredRectangle) Can specialize ancestor behavior (GoldenRectangle) Can use ancestor’s behavior and state Can hide ancestor’s behavior Direct ancestor = superclass Direct descendant = subclass

S.Ducasse 42 Comparable Quantity Hierarchy

S.Ducasse 43 Summary Classes **Describes** the attributes, and relationships of a set of objects Define the behavior of a set of objects Reuse, extend, specialize behavior from other classes Subclasses/superclasses form graph of generalizations

S.Ducasse 44 Summary An object has a state, a behavior and a unique identity. The structure and behavior of similar objects is shared in their class Instances of a class and objects are terms that cn be exchanged Classes as organized in generalisation/specialisation hierarchy What is an instance? What is the difference between instantiation and inheritance?