object-oriented analysis and design for physics...
TRANSCRIPT
![Page 1: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/1.jpg)
1Introduction to OOAD Stefan Kluth
Object-Oriented Analysisand Design
for Physics Programming
![Page 2: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/2.jpg)
2Introduction to OOAD Stefan Kluth
1 Introduction to OOAD
1.1 Overview and Schedule1.2 What is OOAD?1.3 Why OOAD?1.4 Complex Systems1.5 The Object Model
![Page 3: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/3.jpg)
3Introduction to OOAD Stefan Kluth
1.1 Schedule
1) Introduction Monday
2) UML for OOAD Tuesday
3) OO Design: Classes Wednesday
4) OO Design: Packages Thursday
5) OO Analysis Friday
![Page 4: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/4.jpg)
4Introduction to OOAD Stefan Kluth
1.1 LiteratureNot an exhaustive list, but what the lectures are based on
Object-Oriented Analysis and Design with Applications, G. Booch,2nd Ed., Benjamin/Cummings, 1994*
Object Solutions, G. Booch, Addison-Wesley, 1995The Unified Modeling Language User Guide, G. Booch, J. Rumbaugh, I. Jacobson, Addison-Wesley, 1999Agile Software Development: Principles, Patterns and Practices, R. C. Martin, Prentice Hall, 2003&
* 3rd Ed. announced for June 2004& partially available as articles at www.oma.com
![Page 5: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/5.jpg)
5Introduction to OOAD Stefan Kluth
1.1 Expectations
� Who are we?
� What do you expect from this class?
� Have you attended other courses/classes?
� What is your programming experience?
� Do you have a current project?
![Page 6: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/6.jpg)
6Introduction to OOAD Stefan Kluth
1.2 What is OO?
� A method to design and build large programs with a long lifetime
� e.g. O(10k) loc C++ with O(a) lifetime
� Blueprints of systems before coding
� Iterative development process
� Maintainance and modifications
� Control of dependencies
� Separation into components
![Page 7: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/7.jpg)
7Introduction to OOAD Stefan Kluth
1.2 Just another paradigm?
� Object-orientation is closer to the way problems appear in life (physical and non-physical)
� These problems generelly don't come formulated in a procedural manner
� We think in terms of "objects" or concepts and relations between those concepts
� Modelling is simplified with OO because we have objects and relations
![Page 8: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/8.jpg)
8Introduction to OOAD Stefan Kluth
1.2 SA/SD and OO
Data
Function
Function
Function
Function
Function
Function
Function
Data
Function
Data
Top-down hierarchies offunction calls and dependencies
Bottom-up hierarchy of dependencies
![Page 9: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/9.jpg)
9Introduction to OOAD Stefan Kluth
1.2 Common Prejudices
� OO was used earlier without OO languages
� Doubtful. A good procedural program may deal with some of the OO issues but not with all
� OO without language support is at least awkward and dangerous if not quite irresponsible
� It is just common sense and good practices
� It is much more than that, it provides formal methods, techniques and tools to control analysis, design, development and maintainance
![Page 10: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/10.jpg)
10Introduction to OOAD Stefan Kluth
1.3 Why OOAD?
� Software complexity rises exponentially:
� 80's O(10-100) kloc (e.g. JADE)
� 90's O(100) kloc (e.g. OPAL)
� 00's O(1) Mloc (e.g. BaBar, ATLAS)
� Need for tools to deal with complexity OOAD provides these tools
![Page 11: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/11.jpg)
11Introduction to OOAD Stefan Kluth
1.3 Software in HEP Experiments
O(100) kloc, 2000 routines,14 packages
500 kloc, 6900 routines, 54 packages
JADE OPAL
![Page 12: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/12.jpg)
12Object-Oriented Programming in Physics Stefan Kluth GridKa School 29.09.03
1.3 Software in HEP Experiments
O(1) Mloc, O(10k) classes,O(1k) packages
ATLASBaBar
O(1) Mloc, O(1k) classes,O(100) packages
![Page 13: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/13.jpg)
13Introduction to OOAD Stefan Kluth
1.3 Why OOAD in Physics?
� Physics is about modelling the world:
� Objects interact according to laws of nature: particles/fields, atoms, molecules and electrons, liquids, solid states, ...
� OOAD creates models by defining objects and their rules of interaction
� This way of thinking about software is well adapted and quite natural to physicists
� OOAD is a software engineering practice
� manage large projects professionally
![Page 14: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/14.jpg)
14Introduction to OOAD Stefan Kluth
1.4 Complex Systems
� For our purpose complex systems (Booch):
� have many states, i.e. large "phase space",
� are hard to comprehend in total
� hard to predict
� Examples:
� ant colony, an ant
� computer
� weather
� a car
![Page 15: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/15.jpg)
15Introduction to OOAD Stefan Kluth
1.4 Complex Systems
� Attributes of complex systems
� hierarchical
� components
� primitive components
� few kinds of subsystems in many different combinations
� evolved from a simpler system
![Page 16: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/16.jpg)
16Introduction to OOAD Stefan Kluth
1.4 Complex Systems: Hierarchical
� Composed of interrelated subsystems
� subsystems consist of subsystems too
� until elementary component
![Page 17: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/17.jpg)
17Introduction to OOAD Stefan Kluth
1.4 Complex Systems: Components
� Links (dependencies) within a component are stronger than between components
� inner workings of components separated from interaction between components
� service/repair/replace components
![Page 18: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/18.jpg)
18Introduction to OOAD Stefan Kluth
1.4 Complex Systems: Primitive Components
� There are primitive components
� but defintion of primitive may vary
� Nuts, bolts, individual parts?
� replaceable components?
Instrument panelor srews, bulbs and parts?
![Page 19: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/19.jpg)
19Introduction to OOAD Stefan Kluth
1.4 Complex Systems: Few kinds of subsystems in many
combinations
� There are common patterns
� Nuts, bolts, screws interchangeable
� cables, bulbs, plugs
� toothweels, belts, chains
� hoses, clamps
![Page 20: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/20.jpg)
20Introduction to OOAD Stefan Kluth
1.4 Complex Systems: Evolved from a simpler system
� Complex system designed from scratch rarely works
� Add new funtionality/improvements in small steps
![Page 21: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/21.jpg)
21Introduction to OOAD Stefan Kluth
1.4 Complex Systems: Analysis
� Have we seen it before?
� Have we seen its components before?
� Decompose by functionality ("part of")
� Engine, brakes, wheels, lighting
� Decompose by component classes ("is a")
� The BX A8A Turbodiesel is an engine
� Lockheed disk brake is a brake
� 175/65R14 tire+rim is a wheel
![Page 22: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/22.jpg)
22Introduction to OOAD Stefan Kluth
1.4 Complex Systems: Two orthogonal views
� The Object Structure
� "part of" hierarchy, functions
� concentrate on actual components
� concrete
� The Class Structure
� "is a" hierarchy
� concentrate on kinds of components
� abstract
![Page 23: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/23.jpg)
23Introduction to OOAD Stefan Kluth
1.4 Complex Systems: Summary
� Have "large phase space"
� Hard to predict behaviour
� Five properties:
� hierarchies, components, primitives, not too many kinds of components, evolved
� Two orthogonal views for analysis:
� Object Structure ("part of")
� Class Structure ("is a")
![Page 24: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/24.jpg)
24Introduction to OOAD Stefan Kluth
1.5 The Object Model
� Four essential properties
� Abstraction
� Encapsulation
� Modularity
� Hierarchy
� Two more useful properties
� Type
� Persistence
(Booch)
![Page 25: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/25.jpg)
25Introduction to OOAD Stefan Kluth
1.5 AbstractionThe characteristics of an object which make it
unique and reflect an important concept(followingBooch)
Jack
son
Pol
lock
, She
-Wol
f, 19
43
![Page 26: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/26.jpg)
26Introduction to OOAD Stefan Kluth
1.5 EncapsulationSeparates interface of an abstraction
from its implementation
Abstraction: carInterface: steering, pedals,
controlsImplementation:
know, quite differentbetween differentmakes or models
![Page 27: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/27.jpg)
27Introduction to OOAD Stefan Kluth
1.5 ModularityProperty of a system decomposed into cohesive
and loosely coupled modules
Cohesive: group logically relatedabstractions
Loosely coupled: minimise dependenciesbetween modules
![Page 28: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/28.jpg)
28Introduction to OOAD Stefan Kluth
1.5 HierarchyHierarchy is a ranking or ordering of abstractions
PSA A8Aturbo diesel
engineTurbo diesel
engine Dieselengine
Internal combustionengine
VW 1.9TDI
Petrolengine
![Page 29: Object-Oriented Analysis and Design for Physics Programminggraduierten-kurse.physi.uni-heidelberg.de/WiSe2003... · 2008-11-10 · Introduction to OOAD Stefan Kluth 4 1.1 Literature](https://reader033.vdocuments.mx/reader033/viewer/2022041910/5e66ca42f9bf296d37745e13/html5/thumbnails/29.jpg)
29Introduction to OOAD Stefan Kluth
1.5 TypeTyping enforces object class such that objects
of different class may not be interchanged
Strong typing: operation upon an object must be defined,can be checked at compile time
Weak typing: can perform operations on any objectStatic binding: types fixed at compile timeDynamic binding: types fixed at run time
C++, Java: strong + dynamicPerl, Python: weak + dynamicFortran, C: strong + static (ignoring type casts)