Object-Oriented Programming

Slides:



Advertisements
Similar presentations
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Advertisements

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.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Object-Oriented Analysis and Design
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Introduction To System Analysis and Design
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
UML – Class Diagrams.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Essentials of interaction diagrams Lecture Outline Collaborations Interaction on collaboration diagrams Sequence diagrams Messages from an object.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation (Adapted) Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra,
The Unified Modeling Language (UML) Class Diagrams.
UML CLASS DIAGRAMS. Basics of UML Class Diagrams What is a UML class diagram? Imagine you were given the task of drawing a family tree. The steps you.
Unified Modeling Language, Version 2.0
Introduction To System Analysis and Design
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
An Introduction to the Unified Modeling Language
Chapter 10 Classes and Objects In-Depth. Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes,
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Introduction to UML CS A470. What is UML? Unified Modeling Language –OMG Standard, Object Management Group –Based on work from Booch, Rumbaugh, Jacobson.
Radiation Detectors In particular, Silicon Microstrip Detectors by Dr. Darrel Smith.
1 Unified Modeling Language, Version 2.0 Chapter 2.
Chapter 4 Basic Object-Oriented Concepts. Chapter 4 Objectives Class vs. Object Attributes of a class Object relationships Class Methods (Operations)
Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A.
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
Basic Characteristics of Object-Oriented Systems
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
C++ Programming Inheritance
Object-Oriented Design
Object-Orientated Analysis, Design and Programming
Object-Oriented Programming Concepts
Object-oriented and Structured System Models
UML Diagrams By Daniel Damaris Novarianto S..
Roberta Roth, Alan Dennis, and Barbara Haley Wixom
The Movement To Objects
Main issues: • What do we want to build • How do we write this down
Object-Oriented Analysis and Design
Design (2).
Systems Analysis and Design With UML 2
C++ Programming Inheritance
Unified Modeling Language
Introduction to Unified Modeling Language (UML)
Systems Analysis and Design With UML 2
Object Oriented Concepts -I
Object-Oriented Programming
UML Diagrams Jung Woo.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Object Oriented Concepts
Object Oriented Analysis and Design
Unified Modeling Language
Systems Analysis and Design With UML 2
Chapter 20 Object-Oriented Analysis and Design
CIS 375 Bruce R. Maxim UM-Dearborn
Appendix A Object-Oriented Analysis and Design
Analysis models and design models
Copyright 2007 Oxford Consulting, Ltd
Overheads for Computers as Components, 2nd ed.
Basic OOP Concepts and Terms
Overheads for Computers as Components, 2nd ed.
Chapter 22 Object-Oriented Systems Analysis and Design and UML
CIS 375 Bruce R. Maxim UM-Dearborn
Programming For Big Data
Appendix A Object-Oriented Analysis and Design
Agenda Software development (SD) & Software development methodologies (SDM) Orthogonal views of the software OOSD Methodology Why an Object Orientation?
Appendix A Object-Oriented Analysis and Design
Presentation transcript:

Object-Oriented Programming Introduction What is an object Collaboration Among Objects Classes Relationships Between Classes “Use”, “Has”, “Is a” Vocabulary

Introduction ... Let's try for example to see how to implement Bethe-Bloch formula where β = v / c v velocity of the particle E energy of the particle x distance travelled by the particle c speed of light ze particle charge e charge of the electron me rest mass of the electron n electron density of the target I mean excitation potential of the target ...

... Introduction ... In traditional (algorithmic) programming, we would implement a function that uses all parameters CalculateDeDx(v, E, x, c, q, e, me, n, I, ...) This would introduce in our program 10 (or more) independent variables which we would have to handle (initialize, update etc.) In Object-Oriented programming, we first identify the entities with properties which belong together: v velocity of the particle E energy of the particle x distance travelled by the particle q particle charge c speed of light e charge of the electron me rest mass of the electron n electron density of the target I mean excitation potential of the target ... Particle properties Physical constants Material properties

... Introduction When we group the properties in the entities, we can simplify the CalculateDeDx() function: CalculateDeDx(particle, material, constants) We have introduced 3 objects to hold the related variables We can now let the particle to execute CalculateDeDx() using material and constant parameters: particle.CalculateDeDx(material, constants) speed e density speed of light energy charge of e Ion. potential charge mass of e distance Calculate DeDX() Particle Material Constants We have intuitively introduced 3 objects in order to describe the “Bethe-Bloch formula”

What is an object ? “Something you can do things to” (G. Booch) An object = an entity which has its state and behaviour The object retains its state within one or more variables Variable = data appointed by an identifier The object implements its behaviour by the methods Method = function associated with an object State (variables) variable variable Behaviour (methods) variable An object is an entity comprised of variables and methods

What is an object ? Examples of objects: Particle Material speed CalculateDeDx speed e density energy Move charge Ion. potential distance ... Particle Material

Collaboration Among Objects The object appears as a component of a program that contains many other objects It is through the interaction of its objects that the program operates at a higher level of functionality and complexity The objects interact with each other by sending messages The message includes: The message receiver to whom the message is sent (Particle) The name of the method to be executed (CalculateDeDx) The parameter (or parameters) that the method requires (material, constants) CalculateDeDx(material, constants) CalculateDeDx You Particle

Classes In the real world we have a number of objects of the same type: The proton and neutron are two of many particles in the world Speaking OO (Object Oriented) - we say that the proton is an instance of the class of objects known as particles A class is a prototype that declares properties common to a set of objects (variables and methods) It also appears as a mold or a prototype from which it is possible to create objects An instance is a case, a realization of an object CalculateDeDx CalculateDeDx CalculateDeDx 2212 2112 PDG PDG PDG Move charge Move 1 Move charge charge energy energy energy 10 keV 15 keV Proton (An instance) Neutron (An instance) The Particle class

Classes – UML notation UML (Unified modelling language) = a graphical language for modelling data and their treatment Particle PDG charge energy CalculateDeDx() Move() Class name CalculateDeDx PDG Data members or attributes Move charge energy Function members or methods The Particle class If the details of the class are not important in the context, the class can be well represented by a simple rectangle Particle Class name

Encapsulation and Information Hiding ... We differentiate the external from the internal – the interface from the implementation We hide the inside from the clients Don't need to understand the methods and internal variables Unaffected by their nature Unaffected by their changes There is a "wall" around an object No other object can become dependent on internal state and services Public services (Interface) variable variable variable Implementation State (variables) Internal services (not-accessible from outside)

Relationships between Classes "Has" The program design has to define object entities described by the classes and their relations The relationship "Has" A class (A) may contain one or more types (B, C, ...) We say that class A is a composite of class B, C, ... Eg. our class Material may contain a variable which represents a collection of chemical elements that compose the material elements Material Element

Relationships between Classes "Use" The relationship "Use" A class (A) may need to use another class (B) but does not necessarily contain it Typically class A sends messages to class B which is not contained as a data member Eg. Our class Particle defines the method CalculateDeDx which uses as a parameter the objects of type Material and Constants CalculateDeDx(material, ...) Material Particle You

Relationships between Classes "Is a" The relationship "Is a" ( "Inherits from") A class (A) can inherit the state (variables) and behaviour (methods) of another class (B) We say class A is a base class (or a generalization, or a super-type) of class B and class B is a class derived from Class A (or a specialization, or a subtype) For example, leptons, hadrons, bosons are all particles, but belong to different groups, each with their special properties Particle Lepton Hadron Boson

Relationships between Classes "Is a" Derived classes share the same states and the same methods, but they can add their own data members and/or methods Eg. depending on the particle subtype, they may have 2 quarks or 3 quarks Derived classes may also redefine the method inherited from its super-class and provide their specialized implementation Eg. Bethe-Bloch formula is not suitable for calculating DeDx for electrons, we may need to redefine CalculateDeDx()

Vocabulary Object = a computing entity comprised of variables and methods Variable = data appointed by an identifier Method = function associated with an object Message = the means of interaction and communication among objects Class = a prototype that declares properties common to a set of objects (variables and methods) Instance = is a case, a realization of an object of a given class Encapsulation = packaging of object variables behind its methods "Has" = class A has class B if one of its variables is an instance of class B "Use" = class A uses class B if it needs an instance of class B in one of its methods "Is a" = derived class B inherits the state (variables) and behaviour (methods) of base class, A