Object-Oriented Programming

Slides:



Advertisements
Similar presentations
Introduction to Object Orientation System Analysis and Design
Advertisements

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Classes & Objects Computer Science I Last updated 9/30/10.
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
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
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Object Oriented System Development with VB .NET
Fall 2007ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
Basic OOP Concepts and Terms
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation (Adapted) Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra,
Introduction To System Analysis and design
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.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
©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.
CIS 112 Exam Review. Exam Content 100 questions valued at 1 point each 100 questions valued at 1 point each 100 points total 100 points total 10 each.
1/26 On-demand Learning Series Software Engineering of Web Application - Object-Oriented Development & UML Hunan University, Software School.
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,
OBJECT ORIENTED AND FUNCTION ORIENTED DESIGN 1 Chapter 6.
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
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.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Basic Characteristics of Object-Oriented Systems
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.
 The Object Oriented concepts was evolved for solving complex problems. Object- oriented software development started in the 1980s. Object-oriented design.
C++ Programming Inheritance
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Object-Oriented Programming
Object-Oriented Programming
Object-Oriented Design
Object-Oriented Programming Concepts
JAVA By Waqas.
Roberta Roth, Alan Dennis, and Barbara Haley Wixom
The Movement To Objects
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)
OOP What is problem? Solution? OOP
Systems Analysis and Design With UML 2
Object Oriented Concepts -I
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
TIM 58 Chapter 8: Class and Method Design
Object Oriented Concepts
Object Oriented Analysis and Design
INFS 6225 – Object-Oriented Systems Analysis & Design
Chapter 20 Object-Oriented Analysis and Design
Appendix A Object-Oriented Analysis and Design
Workshop for Programming And Systems Management Teachers
Basic OOP Concepts and Terms
CPS120: Introduction to Computer Science
Object-Oriented Programming
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)

Polymorphism ... A class (A) can inherit the state (variables) and behaviour (methods) of another class (B) The relationship "Is a" ( "Inherits from") 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

... Polymorphism 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() Polymorphism An ability to create an object that has more than one form The objects belonging to different types can respond to method, field, or property calls of the same name, each one according to an appropriate type-specific behavior. The programmer (and the program) does not have to know the exact type of the object in advance, and so the exact behavior is determined at run-time (this is called late binding or dynamic binding). When processing a particle of electron type, its special implementation of CalculateDeDx() will be called

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 Polymorphism = ability to handle different objects in a common manner