Object Orientation What, How and Why Will van Beek Independent Consultant www.proWill.nl 18 march 2012.

Slides:



Advertisements
Similar presentations
Object Oriented Programming
Advertisements

OOP Abstraction Classes Class Members: Properties & Methods Instance (object) Encapsulation Interfaces Inheritance Composition Polymorphism Using Inheritance.
CS 350 – Software Design The Bridge Pattern – Chapter 10 Most powerful pattern so far. Gang of Four Definition: Decouple an abstraction from its implementation.
Module 8 “Polymorphism and Inheritance”. Outline Understanding Inheritance Inheritance Diagrams Constructors in Derived Classes Type Compatibility Polymorphism.
SE-1020 Dr. Mark L. Hornick 1 Inheritance and Polymorphism: Abstract Classes The “not quite” classes.
Chapter 10: Introduction to Inheritance
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter N - 1 Chapter 13 Polymorphism is-a relationships Interfaces.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Object-oriented concepts.
Software Engineering Principles and C++ Classes
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter N - 1 Chapter 13 Polymorphism is-a relationships Interfaces.
Object-Orientated Design and Programming Unit 9: Abstract Classes and Interfaces Jin Sa.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 25 More Design Patterns.
CSc 335: Three More OO Design Principles
Svetlin Nakov Telerik Corporation
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Design Dan Fleck CS 421 George Mason University. What is the design phase? Analysis phase describes what the system should do Analysis has provided a.
CS 350 – Software Design The Object Paradigm – Chapter 1 If you were tasked to write code to access a description of shapes that were stored in a database.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
1 Computer Science 340 Software Design & Testing Inheritance.
Data Structures Using C++1 Chapter 1 -Software Engineering Principles -ADT and Classes.
These materials where developed by Martin Schray. Please feel free to use and modify them for non-commercial purposes. If you find them useful or would.
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Objects and Classes Abstract Classes and Interface Sanjaya Karunasena
Peyman Dodangeh Sharif University of Technology Fall 2014.
1 Single Responsibility Principle Open Closed Principle Liskov Substitution Principle Law of Demeter CSC 335: Object-Oriented Programming and Design.
AN OBJECT LESSON IN CLASSES “or how OO ABL solves everything.”
ARCH-11: Building your Presentation with Classes John Sadd Fellow and OpenEdge Evangelist Sasha Kraljevic Principal TSE.
Abstraction ADTs, Information Hiding and Encapsulation.
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Object Oriented Programming
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
It started with a simple … A highly successful duck pond simulation game called SimUDuck The game can show a large variety of duck swimming and making.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
Object- oriented Design Principles
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
Testing in OO Environment The reasons for testing is not any different for any of the design and implementation methodologies, including OO methodology.
COP 4331 – OOD&P Lecture 7 Object Concepts. What is an Object Programming language definition: An instance of a class Design perspective is different.
Industrial Group Project Introduction to Object Oriented Programming Adelina Basholli, February, 2016.
CSCE 240 – Intro to Software Engineering Lecture 3.
1 The Law of Demeter By Rick Mercer with help from Object-Oriented Design Heuristics, Arthur Riel Addison-Wesley, 1996, ISBN X and Applying.
Inheritance New class derived from existing class Software engineering technique Software reuse : faster, easier, cheaper Parent class (supper class):
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Advanced Programming in Java
Object-Oriented Design
Object-Oriented Programming Concepts
Lecture 12 Inheritance.
Advanced Software Concepts
Objects as a programming concept
OOP What is problem? Solution? OOP
C++ Classes & Object Oriented Programming
Object-Orientated Programming
Objects First with Java A Practical Introduction using BlueJ
Object Oriented Analysis and Design
Chapter 10 Thinking in Objects
Advanced Programming Behnam Hatami Fall 2017.
Object Oriented Programming
Objects First with Java A Practical Introduction using BlueJ
Workshop for Programming And Systems Management Teachers
Objects First with Java A Practical Introduction using BlueJ
Object-Oriented PHP (1)
CMPE 135 Object-Oriented Analysis and Design March 7 Class Meeting
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Presentation transcript:

Object Orientation What, How and Why Will van Beek Independent Consultant 18 march 2012

© 2005 Progress Software Corporation2 © 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

© 2005 Progress Software Corporation3 © proWill Basics of Object Orientation.  Abstraction - what is Abstraction ?

© 2005 Progress Software Corporation4 © proWill  What is Abstraction ? Plato’s cave Basics of Object Orientation.

© 2005 Progress Software Corporation5 © 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.

© 2005 Progress Software Corporation6 © 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.

© 2005 Progress Software Corporation7 © 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

© 2005 Progress Software Corporation8 © proWill  Example Person UML Classdiagram Name Class Properties Behavior payAttention break askQuestion attentionLevel satisfactionLevel PreReqsOK Basics of Object Orientation.

© 2005 Progress Software Corporation9 © 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

© 2005 Progress Software Corporation10 © proWill  Delegation Is it really your responsibility ? Principles of Object Orientation

© 2005 Progress Software Corporation11 © proWill Principles of Object Orientation  Encapsulation Interface Implementation

© 2005 Progress Software Corporation12 © proWill  Polymorphism Principles of Object Orientation Interface Implementation comes in many shapes

© 2005 Progress Software Corporation13 © proWill  Polymorphism Start() Marathon EngineDrivingDeviceDiggingSailing Plane MachineProgramSkatingVomittingWritingPinball Principles of Object Orientation

© 2005 Progress Software Corporation14 © proWill  Inheritance Is-a Engine (generic) Engine (Ford) Engine (Volvo) Engine (Volkswagen) Principles of Object Orientation

© 2005 Progress Software Corporation15 © proWill  Delegation  Encapsulation  Polymorphism  Inheritance Principles of Object Orientation – Recap

© 2005 Progress Software Corporation16 © 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

© 2005 Progress Software Corporation17 © proWill Differences with Procedural Programming.

© 2005 Progress Software Corporation18 © 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.

© 2005 Progress Software Corporation19 © proWill The Reality of Procedural Programming

© 2005 Progress Software Corporation20 © proWill The Reality of Procedural Programming

© 2005 Progress Software Corporation21 © proWill The Reality of Procedural Programming  Rigidity  Fragility  Immobility Can we do better ?

© 2005 Progress Software Corporation22 © 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

© 2005 Progress Software Corporation23 © 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

© 2005 Progress Software Corporation24 © 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

© 2005 Progress Software Corporation25 © 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

© 2005 Progress Software Corporation26 © proWill Example – the Animal Farm

© 2005 Progress Software Corporation27 © proWill Demo

© 2005 Progress Software Corporation28 © proWill The Procedural way Encapsulation Delegation

© 2005 Progress Software Corporation29 © proWill The Procedural way Fragile Rigid

© 2005 Progress Software Corporation30 © 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

© 2005 Progress Software Corporation31 © proWill The Object Oriented way  Let’s talk Interface – how to operate the animals makeSound

© 2005 Progress Software Corporation32 © proWill The Object Oriented way – the iAnimal interface class function makeSound returns logical private().

© 2005 Progress Software Corporation33 © 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

© 2005 Progress Software Corporation34 © 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

© 2005 Progress Software Corporation35 © 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

© 2005 Progress Software Corporation36 © 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

© 2005 Progress Software Corporation37 © proWill Implementations – the animal class

© 2005 Progress Software Corporation38 © proWill Implementations – the cat class

© 2005 Progress Software Corporation39 © proWill Implementations – the dog class

© 2005 Progress Software Corporation40 © proWill Implementations – the cow class

© 2005 Progress Software Corporation41 © proWill Implementations – the borg class

© 2005 Progress Software Corporation42 © proWill Encapsulation / Delegation – animalFarm animalFarm.cls - Animal as iAnimal + visitAnAnimal(pcName)

© 2005 Progress Software Corporation43 © proWill Encapsulation / Delegation – visit animalFarm.cls - Animal as iAnimal + visitAnAnimal(pcName) visit.cls + animalFarm start.p

© 2005 Progress Software Corporation44 © proWill Implementations – the animalFarm class

© 2005 Progress Software Corporation45 © proWill Implementations – the visit class

© 2005 Progress Software Corporation46 © proWill Implementations – the start procedure

© 2005 Progress Software Corporation47 © proWill Questions?

© 2005 Progress Software Corporation48 © proWill Thanks you for your time

© 2005 Progress Software Corporation49 © proWill proWillvanBeek Keep in touch