Design Strategies in OO Development

Slides:



Advertisements
Similar presentations
Object-Oriented Programming Basics Prof. Ankur Teredesai, Computer Science Department, RIT.
Advertisements

Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Informática II Prof. Dr. Gustavo Patiño MJ
Abstraction Lecture-4. ADT example: London Underground Map.
Introduction To System Analysis and Design
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
Designing Classes OO Software Design and Construction Computer Science Dept Va Tech January 2002 ©2002 McQuain WD & Keller BJ 1 Designing the Classes Once.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
CS 325: Software Engineering March 17, 2015 Applying Patterns (Part A) The Façade Pattern The Adapter Pattern Interfaces & Implementations The Strategy.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Introduction To System Analysis and Design
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
CS 4310: Software Engineering Lecture 4 System Modeling The Analysis Stage.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Fall 2010 CS4310 Requirements Engineering A Brief Review of UML & OO Dr. Guoqiang Hu Department of Computer Science UTEP 1.
1 What is OO Design? OO Design is a process of invention, where developers create the abstractions necessary to meet the system’s requirements OO Design.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
Simple Classes. ADTs A specification for a real world data item –defines types and valid ranges –defines valid operations on the data. Specification is.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
OBJECT ORIENTED AND FUNCTION ORIENTED DESIGN 1 Chapter 6.
Identifying Classes OO Software Design and Construction Computer Science Dept Va Tech January 2002 ©2002 McQuain WD & Keller BJ 1 Getting Started In the.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
C++ Inheritance Data Structures & OO Development I 1 Computer Science Dept Va Tech June 2007 © McQuain Generalization versus Abstraction Abstraction:simplify.
OOP Review CS 124.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Chapter 10 Software quality. This chapter discusses n Some important properties we want our system to have, specifically correctness and maintainability.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
CSCE 240 – Intro to Software Engineering Lecture 3.
Introduction: Databases and Database Systems Lecture # 1 June 19,2012 National University of Computer and Emerging Sciences.
Chapter 11: Abstract Data Types Lecture # 17. Chapter 11 Topics The Concept of Abstraction Advantages of Abstract Data Types Design Issues for Abstract.
Maitrayee Mukerji. INPUT MEMORY PROCESS OUTPUT DATA INFO.
Software Engineering Lecture 4 System Modeling The Analysis Stage.
Sachin Malhotra Saurabh Choudhary
Object-Oriented Programming Basics
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
MPCS – Advanced java Programming
Concepts of Object Orientation
Introduction to Design Patterns
Unified Modeling Language
Software Quality Engineering
Abstract descriptions of systems whose requirements are being analysed
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
SNSCT_CSE_PROGRAMMING PARADIGM_CS206
 DATAABSTRACTION  INSTANCES& SCHEMAS  DATA MODELS.
Object-Oriented Design
Chapter 20 Object-Oriented Analysis and Design
DESIGNING YOUR SYSTEM.
An Introduction to Software Architecture
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
Introduction to Data Structure
Applying Use Cases (Chapters 25,26)
Applying Use Cases (Chapters 25,26)
Software Analysis.
Chapter 22 Object-Oriented Systems Analysis and Design and UML
Object-Oriented PHP (1)
CS 2704 Object Oriented Software Design and Construction
Software Engineering Basics
Agenda Software development (SD) & Software development methodologies (SDM) Orthogonal views of the software OOSD Methodology Why an Object Orientation?
UML  UML stands for Unified Modeling Language. It is a standard which is mainly used for creating object- oriented, meaningful documentation models for.
From Use Cases to Implementation
Presentation transcript:

Design Strategies in OO Development CS 2704 Object Oriented Software Design and Construction May 5, 2019 Design Strategies in OO Development Identifying objects (and services or operations) is the key to a good OO design. A class is an explicit abstraction (model) of a problem domain entity. Abstractions come from the problem domain. Programming is a modeling activity. Separation is the division of interface from implementation. Realization of the principle of information hiding. Composition views a complex system as an organized collection of simpler parts. Understanding the interactions (relationships, collaborations, etc.) of the parts is vital. Generalization is the identification of the shared properties of problem model abstractions and the organized exploitation of same. Look for quantifiers like "all" and "every". This diagram represents the principal connections. Understanding the connections will aid in creating well-designed systems. Relationships will only be understood after intense study and practice of OOD and OOP. Structures relate to 3 of the r design strategies. The forms of generalization relate to all of the SE goals. Abstraction modeling essential properties Separation treat what and how independently Composition building complex structures from simpler ones Generalization identifying common elements abstraction separation composition generalization Design Strategies objects classes inheritance templates design patterns Software Structures extensibility flexibility reusability Software Engineering Goals Kafura OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

CS 2704 Object Oriented Software Design and Construction May 5, 2019 Abstraction Hills, buildings and cossacks with lances. The artist only shows the essential, distinguishing characteristics of each entity. Modeling entities (real world or conceptual) in software An abstraction distills something to its essential properties. The properties that make it what it is and distinguish it from others. Simplifies complex problems Only essential aspects should be included: attributes = properties, characteristics, information behavoir = actions When you say “car,” people get a picture of a generic, or “abstract,” thing with certain properties: wheels, speed, direction, number of passengers, number of axles and behavior: accelerate, brake, stop, turn right, turn left, etc. Modeling entities in software Only essential aspects should be captured attributes behavior Wassily Kandinski Cossacks, 1910-11 OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

Practical Abstraction CS 2704 Object Oriented Software Design and Construction May 5, 2019 Practical Abstraction Practical abstractions. These shapes convey the essential distinguishing characteristics of a male and female (in our society). Critique?? Kafura OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

CS 2704 Object Oriented Software Design and Construction May 5, 2019 Abstraction Attribute and behavior identification (usually these are not completely identified in systems analysis/requirements documents): How is the object described in general? What parts of the general description are applicable to this problem domain? What is the minimal description needed for this application? Tradeoff: capturing more specific attributes and behaviors may result in objects that are more efficient in time/space, but also are less flexible and reusable. But for software, an abstraction is not a philosophical, ethereal concern. In development, abstractions are refined throughout the life of a piece of software. We start with hand-made lists, and progress through various formal methods, sometimes using software tools. The implementation in source code is the ultimate expression of a software abstraction. Name: to distinguish from other abstractions Attributes and behavior: the essential elements of an abstraction. Modeling: what software is all about Purpose: appropriate abstractions are different for different purposes. Book example of a salesperson abstraction from two perspectives. One is the sales system, number of cars sold is important other is medical system, which couldn’t care less about number sold Well named: clearly conveys aspects of the abstraction Whether it is meaningful depends on the audience. Coherent: makes sense Accurate: contains only the attributes the modeled entity contains. Note VR exception Minimal: only the attributes needed for the purpose of the abstraction. For example, hair color is irrelevant for a billing system. Complete: All the attributes and behavior needed for the purpose of the software. These are all subjective. Judgement through experience are needed. A named collection of attributes and behavior relevant to modeling a given entity for some particular purpose. Desirable Properties: well named name conveys aspects of the abstraction coherent makes sense accurate contains only attributes modeled entity contains minimal contains only attributes needed for the purpose complete contains all attributes and behavior needed for the purpose OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

CS 2704 Object Oriented Software Design and Construction May 5, 2019 Better Abstractions These abstractions illustrates properties of a “good” abstraction: well named (for English-speakers) coherent accurate (culture sensitive representations – Scotland?, ME?) minimal complete Is gender an attribute or a behavior or a class?? Depends upon the system in question. If none of the relevant, modeled behaviors of any of the entities in the system are gender-specific then gender is an attribute. Otherwise, gender is a class. MEN WOMEN OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

Mapping Abstraction to Software CS 2704 Object Oriented Software Design and Construction May 5, 2019 Mapping Abstraction to Software There is a great danger that abstractions will get lost in programming details. Avoid compromising the abstraction. There is inevitably a loss of precision and completeness when crossing the first boundary. No abstraction can capture the entirety of its inspiration. The designer must determine which attributes and behaviors are essential and which are not. Ideally, the transition across the second boundary should not involve any loss of precision. In practice there will be loss of precision here due to limitations of the implementation tools (e.g., type double versus the set of real numbers). real-world abstraction software entity attributes behavior {data, data,…} {method, method,…} Kafura OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

Separation of Interface from Implementation CS 2704 Object Oriented Software Design and Construction May 5, 2019 Separation of Interface from Implementation What is to be done versus How it is done what/how, goal/plan, policy/mechanism, product/process, ends/means Simpler to express what versus how. Requirements analysis specifies what, programmers implement the how. In programming, the independent specification of an interface and one or more implementations of that interface. Interface Implementation visible hidden What is to be done vs How it is to be done OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

Interchangeability of Implementations CS 2704 Object Oriented Software Design and Construction May 5, 2019 Interchangeability of Implementations Flexibility. Different implementations can satisfy the same interface. Perhaps the implementations differ in price, reliability, location, etc. Implementations of the same interface are called “plug compatible” Allows the creation of multiple implementations with a common interface. For example: a List ADT could use a dynamic linked list or a dynamic array for the underlying physical data structure. In either case, the same interface would be appropriate (and the user need not be concerned with the underlying structure in many cases). interface implementation2 implementation1 Implementations that share a common interface are said to be “plug compatible”. They may differ in algorithmic complexity, reliability, platform dependencies, etc. OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

Specificity of Interface CS 2704 Object Oriented Software Design and Construction May 5, 2019 Specificity of Interface An implementation can satisfy more than one interface. This allows the isolation of restricted set used in one situation versus another Suppose there is a more efficient implementation of TextInterface that we want to use in a critical part of the system. Also allows a single implementation to support multiple interfaces. This allows the isolation of restricted set used in one situation versus another LList implementation Stack For example, we could have a very general List ADT that supported both standard List operations, and also Stack operations. By “subsetting” the functionality of the ADT into separate interfaces, we could provide both categories of operation, in a natural way, without duplication of shared code. In essence, we view the implementation as a library of related widgets. OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

Mapping Abstraction to Software in OO CS 2704 Object Oriented Software Design and Construction May 5, 2019 Mapping Abstraction to Software in OO You can model an abstraction in any software language. Prior to O-O, the notion of encapsulating data and operations together was called an Abstract Data Type. But O-O facilitates modeling these kinds of abstractions by using Classes and Objects. real-world abstraction OO software entity attributes behavior {data, data,…} {method, method,…} OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

General Structure of a Class CS 2704 Object Oriented Software Design and Construction May 5, 2019 General Structure of a Class The software model of an abstraction. Class is the definition of the attributes and behavior with implementation. “Class” is used to convey that it represents all members of a group Separation: two parts to a class, public interface, private data and implementation. Hiding data is important so that other developers using the class do not erroneously change it. Hide it and they cannot get to it. Private implementation also hides the algorithm. This is sometimes called “encapsulation.” Class: a named software representation for an abstraction that separates the implementation of the representation from the interface of the representation. Some methods may be private, in fact this is common. Some data may be public, this should not be common. Some OO languages do not use classes. E.g., “Self” uses prototypes class: a named software representation for an abstraction that separates the implementation of the representation from the interface of the representation A class models an abstraction, which models an entity (possibly “real”). A class represents all members of a group of objects (“instances” of the class). A class provides a public interface and a private implementation. The hiding of the data and “algorithm” from the user is important. Access restrictions prevent idle or malicious alterations. private public className {data, data, ….} {method,method, …} typical organization OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

General Structure of an Object CS 2704 Object Oriented Software Design and Construction May 5, 2019 General Structure of an Object A specific member of a class. Interface and Implementation are separate The object “encapsulates” its data Encapsulation: in o-o programming, the restriction of access to data within an object to only those members defined by the object’s class. Multiple objects are created from a single class definition. Object: A distinct instance of a given class that encapsulates its implementation details and is structurally identical to all other instances of that class. object: a distinct instance of a given class that encapsulates its implementation details and is structurally identical to all other instances of that class An object “encapsulates” its data and the operations that may be performed on that data. An object’s private data may ONLY be accessed via the member functions defined within the object’s class. An object hides details of representation and implementation from the user. code . data method implementation interface C++ note: Privacy restrictions are enforced at the class level, NOT the object level. That is, if A and B are of the same type, and A knows B’s name, then A can access the private members of B directly. OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

Separation and Classes CS 2704 Object Oriented Software Design and Construction May 5, 2019 Separation and Classes If we have two different classes, objects of each can see only the (public) interfaces of the objects of the other. class A implementation provides methods class B implementation can use class A methods identified in the class A interface class A interface identifies available methods OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

Multiple Instances of a Class CS 2704 Object Oriented Software Design and Construction May 5, 2019 Multiple Instances of a Class Each instance, or object, usually has different values for the class-defined properties. Class=Factory Objects=products Side point (if there’s time) When developing abstractions, or classes, it may help to think of them as people-like entities with responsibilities and collaborators . Responsibilities of knowing (respond with information to a query) Responsibilities of doing (act on something, transform, move, sort, etc.) Collaborators: associated objects in the system with their own responsibilities (association is next week) SalesPerson private public Name commissionRate totalSales sellCar reportSales Joe Hokie 16% $250.000 Jill Hokie $275.000 Each instance, or object, usually has different values for the class-defined properties. Class = Factory Objects = Products When developing abstractions, or classes, it may help to think of them as people-like entities with responsibilities and collaborators. Responsibilities of knowing (respond with information to a query) Responsibilities of doing (act on something, transform, move, sort, etc.) Collaborators: associated objects in the system with their own responsibilities OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ

Software Engineering Goals CS 2704 Object Oriented Software Design and Construction May 5, 2019 Software Engineering Goals Objects and classes help programmers achieve a primary software-engineering goal: reusability A single class is used repeatedly to create multiple object instances. More importantly, encapsulation prevents other developers from inadvertently modifying an object’s data. Separation allows different implementations to be used for an interface. Objects and classes help programmers achieve a primary software-engineering goal: reusability A single class is used repeatedly to create multiple object instances. More importantly, encapsulation prevents other developers from inadvertently modifying an object’s data. Separation allows different implementations to be used for an interface. objects classes inheritance templates design patterns Software Structures extensibility flexibility reusability Software Engineering Goals OO Design Introduction Computer Science Dept Va Tech January 2002 ©2000-2002 McQuain WD & Keller BJ