Why OO Paradigm is better?

Slides:



Advertisements
Similar presentations
Reusable Classes.  Motivation: Write less code!
Advertisements

Object Oriented Programming in Java. Object Oriented Programming Concepts in Java Object oriented Programming is a paradigm or organizing principle for.
General OO Concepts and Principles CSE301 University of Sunderland Harry R. Erwin, PhD.
SOLID Object Oriented Design Craig Berntson
Introduction to Object Oriented Programming Java.
Imperative Programming Paradigm. Procedural Programming.
Chapter 25 GRASP: More Objects with Responsibilities 1CS6359 Fall 2011 John Cole.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter N - 1 Abstract Superclasses and Abstract Methods When.
Developed by Reneta Barneva, SUNY Fredonia Component Level Design.
Software Issues Derived from Dr. Fawcett’s Slides Phil Pratt-Szeliga Fall 2009.
C++ fundamentals.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
August 22, August 22, 2015August 22, 2015August 22, 2015 Azusa, CA Sheldon X. Liang Ph. D. Software Engineering in CS at APU Azusa Pacific University,
Copyright © 2002, Systems and Computer Engineering, Carleton University Intro.ppt * Object-Oriented Software Development Unit 1 Course.
Introduction to Object-oriented programming and software development Lecture 1.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
1 OO Design Novosoft, 2001 by V. Mukhortov. 2 OO Design Goals  Flexibility Changes must be localized  Maintainability Modules requiring changes can.
Ceg860 (Prasad)L6MR1 Modularity Extendibility Reusability.
CSC 395 – Software Engineering Lecture 12: Reusability –or– Programming was Bjarne Again.
Software reuse means to “borrow” existing code. How can you reuse an existing class to make a new one? Such reuse is really an adaptation -- using the.
© 2004 Capgemini - All rights reserved SOLID - OO DESIGN PRINCIPLES Andreas Enbohm, Capgemini.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
Pattern Hatching - John Vlissides Pages 85 – 101 Todd Anderson
Introduction to SOLID Principles. Background Dependency Inversion Principle Single Responsibility Principle Open/Closed Principle Liskov Substitution.
CSSE 374: More GRASP’ing for Object Responsibilities
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
S.O.L.I.D. Software Development 12 January 2010 (Martin Verboon, Patrick Kalkman, Stan Verdiesen)
CSSE501 Object-Oriented Development. Some OO Design Principles  Majority principles here come from: Design Principles in Java, Bob Tarr.
Frameworks & Patterns Use of Organized Classes. Frameworks vs Toolkits Framework Framework  Start with classes and interfaces that define a rudimentary.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
OO Design Principles Copyright © Vyacheslav Mukhortov, Nikita Nyanchuk-Tatarskiy, Copyright © INTEKS LLC,
Abstraction ADTs, Information Hiding and Encapsulation.
1 Chapter 5:Design Patterns. 2 What are design pattern?  Schematic description of design solution to recurring problems in software design and,  Reusable.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Chapter 1 Data Abstraction: The Walls CS Data Structures Mehmet H Gunes Modified from authors’ slides.
SOLID Design Principles
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
CSE 2341 Object Oriented Programming with C++ Note Set #4
9.1 CLASS (STATIC) VARIABLES AND METHODS Defining classes is only one aspect of object-oriented programming. The real power of object-oriented programming.
Modular Decomposition, Abstraction and Specifications
Course information Old exam Resit Report Result and walkthrough
Design Patterns Source: “Design Patterns”, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides And Created.
Design Patterns: MORE Examples
Object Oriented Programming
Inheritance ITI1121 Nour El Kadri.
Chapter 5:Design Patterns
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
Chapter 1 Data Abstraction: The Walls
Satisfying Open/Closed Principle
The Object-Oriented Thought Process Chapter 05
lecture 08, OO Design Principle
Object-Oriented Programming
Week 6 Object-Oriented Programming (2): Polymorphism
OO Design Patterns - Decorator
Decorator Pattern Richard Gesick.
Generation Gap By Kurt Rehwinkel
Subtype Polymorphism, Subtyping vs
Software Design Lecture : 12.
Software Design Lecture : 11.
Software Design Lecture : 14.
Object-Oriented Programming
Handout-2(b) Dr. R. Z. Khan AMU. Aligarh (INDIA).
A (partial) blueprint for dealing with change
Principles of Object-Oriented Design
Object-Oriented PHP (1)
Chapter 8, Design Patterns Introduction
Object Oriented Design & Analysis
HFOOAD Chapter 5 Interlude
DESIGN CONCEPTS AND PRINCIPLES
Presentation transcript:

Why OO Paradigm is better? 2/25/2019 Why OO is better

Problem Consider the following problem: A philatelist owns a number of stamps, which can be divided into group I and group II. Each stamp has a name, face value, and publication year. Also, each stamp has a commercial value: the commercial value of group I is equal to the face value while the commercial value of group II is twice as much as the face value. So write a program to calculate the commercial value of all stamps owned by a philatelist. 2/25/2019 Why OO is better

Your Client Code After you finish the previous program, write a client to model the following scenario: John is a philatelist owing the following stamp (name, face value, group, pub year): Shot Put, 75c, II, 1984 Men’s Gym, 100c, II, 1984 Weight Lift, 150c, II, 1984 Niagara Falss, 80c, I, 1999 Acadia Maine, 60c, I , 2000 Yosemite, 84c, I, 2001 Mile Woods, 72c, I, 2007 2/25/2019 Why OO is better

Example John owns 7 stamps: group I and group II. How to calculate the commercial value of the stamps owned by John. struct stamp { float face_value; int group} a[7]; float com_value () { … for (i=0;i<7,i++) if a[i].group==1 total += a[i].face_value; else total += 2 * a[i].face_value; } Program Domain 2/25/2019 Why OO is better

OO Solution Class Philatelist { private float stamp[7]; public float com_value () { … for (i=0;i<7,i++) if a[i].group==1 total += a[i].face_value; else total+=2*a[i].face_value; } Class Philatelist { private Stamp stamp[7]; public float com_value () { … for (i=0;i<7,i++) total+=a[i].com_value(); } Stamp float face_value float com_value() GroupI_Stamp GroupII_Stamp 2/25/2019 Why OO is better

OO Design Principles 2/25/2019 Why OO is better

Principle The Open-Closed Principle: Software Entities Should be Open For Extension, Yet Closed For Modification 2/25/2019 Why OO is better

Open-Closed Principle The open-closed principle (OCP) says that we should attempt to design modules that never need to be changed. To extend the behavior of the system, we need to add code. We do not modify old code Modules that conform to OCP meet two criteria: Open for Extension – the behavior of the module can be extended to meet new requirements Closed for modification – the source code of the module is not allowed to change How can we do this Inheritance Abstraction Polymorphism Interface 2/25/2019 Why OO is better

Open-Closed Principle It is not possible to have all the methods of a software system satisfy the OCP, but we should minimize the number of modules that do not satisfy it. The OCP is really the heart of OO design Conformance to this principle yields the greatest of reusability and maintainability. 2/25/2019 Why OO is better

OCP Example In the Philatelist example, we use polymorphism to calculate the commercial value: Class Philatelist { private Stamp stamp[7]; public float com_value () { … for (i=0;i<7,i++) total+=a[i].com_value(); } 2/25/2019 Why OO is better

OCP Example Calculation in Class Philatelist becomes flexible if we use inheritance to represent the different categories of a stamp. Stamp float com_value() GroupI_Stamp GroupIII_Stamp GroupII_Stamp 2/25/2019 Why OO is better