Download presentation
Presentation is loading. Please wait.
Published byErnest Craig Modified over 8 years ago
1
Object Orientation What, How and Why Will van Beek Independent Consultant www.proWill.nl 18 march 2012
2
© 2005 Progress Software Corporation2 © - 2012 - proWill What is Object Orientation ? Basics & Principles Why use Object Orientation ? How to use Object Orientation Demo – the Animal Farm Object Orientation – What, How and Why
3
© 2005 Progress Software Corporation3 © - 2012 - proWill Basics of Object Orientation. Abstraction - what is Abstraction ?
4
© 2005 Progress Software Corporation4 © - 2012 - proWill What is Abstraction ? Plato’s cave Basics of Object Orientation.
5
© 2005 Progress Software Corporation5 © - 2012 - proWill What is Abstraction ? Plato’s cave. Abstraction = model / derivative of reality. Modeling Grouping relevant properties and behavior in unambiguous classes. Basics of Object Orientation.
6
© 2005 Progress Software Corporation6 © - 2012 - proWill Abstraction = model of reality What is a Class(ification) ? Aristotle Animal sponges worms arthropods vertebrates flies lobsters spiders reptiles mammals Basics of Object Orientation.
7
© 2005 Progress Software Corporation7 © - 2012 - proWill Abstraction = model of reality Class = abstract definition of properties, behavior and relations to other classes What is an Object ? Concrete instance of a class. Basics of Object Orientation. Example
8
© 2005 Progress Software Corporation8 © - 2012 - proWill Example Person UML Classdiagram Name Class Properties Behavior payAttention break askQuestion attentionLevel satisfactionLevel PreReqsOK Basics of Object Orientation.
9
© 2005 Progress Software Corporation9 © - 2012 - proWill What is Object Orientation ? Basics & Principles Why use Object Orientation ? How to use Object Orientation Demo – the Animal Farm Object Orientation – What, How and Why
10
© 2005 Progress Software Corporation10 © - 2012 - proWill Delegation Is it really your responsibility ? Principles of Object Orientation
11
© 2005 Progress Software Corporation11 © - 2012 - proWill Principles of Object Orientation Encapsulation Interface Implementation
12
© 2005 Progress Software Corporation12 © - 2012 - proWill Polymorphism Principles of Object Orientation Interface Implementation comes in many shapes
13
© 2005 Progress Software Corporation13 © - 2012 - proWill Polymorphism Start() Marathon EngineDrivingDeviceDiggingSailing Plane MachineProgramSkatingVomittingWritingPinball Principles of Object Orientation
14
© 2005 Progress Software Corporation14 © - 2012 - proWill Inheritance Is-a Engine (generic) Engine (Ford) Engine (Volvo) Engine (Volkswagen) Principles of Object Orientation
15
© 2005 Progress Software Corporation15 © - 2012 - proWill Delegation Encapsulation Polymorphism Inheritance Principles of Object Orientation – Recap
16
© 2005 Progress Software Corporation16 © - 2012 - proWill What is Object Orientation Why use Object Orientation ? Differences with Procedural Programming How to use Object Orientation Demo – the Animal Farm Object Orientation – What, How and Why
17
© 2005 Progress Software Corporation17 © - 2012 - proWill Differences with Procedural Programming.
18
© 2005 Progress Software Corporation18 © - 2012 - proWill The Reality of Procedural Programming define variable hProc as handle no-undo. for each superProc: run value(superProc.fileName) persistent set hProc. session:add-super-procedure(hProc). end.
19
© 2005 Progress Software Corporation19 © - 2012 - proWill The Reality of Procedural Programming
20
© 2005 Progress Software Corporation20 © - 2012 - proWill The Reality of Procedural Programming
21
© 2005 Progress Software Corporation21 © - 2012 - proWill The Reality of Procedural Programming Rigidity Fragility Immobility Can we do better ?
22
© 2005 Progress Software Corporation22 © - 2012 - proWill What is Object Orientation ? Why use Object Orientation ? How to use Object Orientation Principles of sound design Demo – the Animal Farm Object Orientation – What, How and Why
23
© 2005 Progress Software Corporation23 © - 2012 - proWill Principles of Good / Sound Design. Low & Loose Coupling (Law Of Demeter) Don’t talk to strangers ! An object knows only about himself and its direct parent (Superclass) The principle of least knowledge High coupling inextricably Lots of classes with different functionality inextricably connected Swiss Knife Classes
24
© 2005 Progress Software Corporation24 © - 2012 - proWill Principles of Good / Sound Design. High Cohesion Do only 1 thing ! All other responsibilities have been moved to other classes The principle of single responsibility Low Cohesion Different functionalities in 1 class
25
© 2005 Progress Software Corporation25 © - 2012 - proWill What is Object Orientation ? Why use Object Orientation ? How to use Object Orientation Demo – the Animal Farm the Procedural way the Object Oriented way Object Orientation – What, How and Why
26
© 2005 Progress Software Corporation26 © - 2012 - proWill Example – the Animal Farm
27
© 2005 Progress Software Corporation27 © - 2012 - proWill Demo
28
© 2005 Progress Software Corporation28 © - 2012 - proWill The Procedural way Encapsulation Delegation
29
© 2005 Progress Software Corporation29 © - 2012 - proWill The Procedural way Fragile Rigid
30
© 2005 Progress Software Corporation30 © - 2012 - proWill The Object Oriented way Let’s talk Interface – how to operate the coffee machine Where to put the cup, the coffee & the water How to turn it On/Off
31
© 2005 Progress Software Corporation31 © - 2012 - proWill The Object Oriented way Let’s talk Interface – how to operate the animals makeSound
32
© 2005 Progress Software Corporation32 © - 2012 - proWill The Object Oriented way – the iAnimal interface class function makeSound returns logical private().
33
© 2005 Progress Software Corporation33 © - 2012 - proWill Access Modifiers AccessModifier - private + public define public variable cTest as character no-undo.define private variable cTest as character no-undo.define protected variable cTest as character no-undo. # protected sub super
34
© 2005 Progress Software Corporation34 © - 2012 - proWill Polymorphism – one interface, multiple implementations iAnimal.cls + makeSound cat.cls + makeSound dog.cls + makeSound cow.cls + makeSound borg.cls + makeSound System.Media. Soundplayer + SoundLocation + Play 1. Initiate the animal’s vocal cords 2. Specify the name of the sound file 3. Play the sound file 1. Initiate the animal’s vocal cords 2. Specify the name of the sound file 3. Play the sound file
35
© 2005 Progress Software Corporation35 © - 2012 - proWill Inheritance – a cat/dog/cow/borg is-an animal iAnimal.cls + makeSound System.Media. Soundplayer + SoundLocation + Play cat.cls + makeSound dog.cls + makeSound cow.cls + makeSound borg.cls + makeSound animal.cls - vocalCords # soundFile - initializeVocalCords + makeSound
36
© 2005 Progress Software Corporation36 © - 2012 - proWill Encapsulation / Delegation – vocalCords iAnimal.cls + makeSound System.Media. Soundplayer + SoundLocation + Play cat.cls + makeSound dog.cls + makeSound cow.cls + makeSound borg.cls + makeSound animal.cls - vocalCords # soundFile - initializeVocalCords + makeSound
37
© 2005 Progress Software Corporation37 © - 2012 - proWill Implementations – the animal class
38
© 2005 Progress Software Corporation38 © - 2012 - proWill Implementations – the cat class
39
© 2005 Progress Software Corporation39 © - 2012 - proWill Implementations – the dog class
40
© 2005 Progress Software Corporation40 © - 2012 - proWill Implementations – the cow class
41
© 2005 Progress Software Corporation41 © - 2012 - proWill Implementations – the borg class
42
© 2005 Progress Software Corporation42 © - 2012 - proWill Encapsulation / Delegation – animalFarm animalFarm.cls - Animal as iAnimal + visitAnAnimal(pcName)
43
© 2005 Progress Software Corporation43 © - 2012 - proWill Encapsulation / Delegation – visit animalFarm.cls - Animal as iAnimal + visitAnAnimal(pcName) visit.cls + animalFarm start.p
44
© 2005 Progress Software Corporation44 © - 2012 - proWill Implementations – the animalFarm class
45
© 2005 Progress Software Corporation45 © - 2012 - proWill Implementations – the visit class
46
© 2005 Progress Software Corporation46 © - 2012 - proWill Implementations – the start procedure
47
© 2005 Progress Software Corporation47 © - 2012 - proWill Questions?
48
© 2005 Progress Software Corporation48 © - 2012 - proWill Thanks you for your time
49
© 2005 Progress Software Corporation49 © - 2012 - proWill www.proWill.nl progressTrainer@live.com info@proWill.nl proWillvanBeek http://nl.linkedin.com/in/proWill +316 2206 8535 Keep in touch
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.