Object-Oriented Design

Similar documents
Object-Oriented Design

Object-Oriented Design

Object-Oriented Design

Chapter 5 Object-Oriented Programming

Introduction to Unified Modelling Language (UML)

Chapter 8: Class and Method Design

CHAPTER 9 DESIGN ENGINEERING. Overview

Object-Oriented Design

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Object Orientated Analysis and Design. Benjamin Kenwright

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

An Introduction to Patterns

What are the characteristics of Object Oriented programming language?

Object-Oriented Design

Chapter 11 Object and Object- Relational Databases

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

INTERNAL ASSESSMENT TEST III Answer Schema

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

New Programming Paradigms

Object-Oriented Design

REVIEW OF THE BASIC CHARACTERISTICS OF OBJECT ORIENTATION

What about Object-Oriented Languages?

In this Lecture you will Learn: Design Patterns. Patterns vs. Frameworks. Patterns vs. Frameworks

Inheritance (Chapter 7)

UNIT I. 3. Write a short notes on process view of 4+1 architecture. 4. Why is object-oriented approach superior to procedural approach?

Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1

Object-Oriented Concepts and Design Principles

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming

Accessibility. EEC 521: Software Engineering. Classes and Objects. Inheritance. Classes and Objects (OO Analysis)

Final Exam. Final Exam Review. Ch 1: Introduction: Object-oriented analysis, design, implementation. Exam Format

OBJECT ORIENTED SYSTEM DEVELOPMENT Software Development Dynamic System Development Information system solution Steps in System Development Analysis

Patterns and Testing

Chapter 1: Programming Principles

The following topics will be covered in this course (not necessarily in this order).

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

Software Engineering with Objects and Components Open Issues and Course Summary

Objectives. Explain the purpose and objectives of objectoriented. Develop design class diagrams

Introduction to UML. Danang Wahyu utomo

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects

Introduction to Software Engineering. 5. Modeling Objects and Classes

Component Design. Systems Engineering BSc Course. Budapest University of Technology and Economics Department of Measurement and Information Systems

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Software Service Engineering

Java Object Oriented Design. CSC207 Fall 2014

Object Relationships

Appendix A - Glossary(of OO software term s)

Design Process Overview. At Each Level of Abstraction. Design Phases. Design Phases James M. Bieman

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Object-Oriented Design

Chapter 1: Principles of Programming and Software Engineering

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language

SOFTWARE MODELING AND DESIGN. UML, Use Cases, Patterns, and. Software Architectures. Ki Cambridge UNIVERSITY PRESS. Hassan Gomaa

Object-Oriented Software Engineering Practical Software Development using UML and Java

History of object-oriented approaches

Introduction to UML What is UML? Motivations for UML Types of UML diagrams UML syntax Descriptions of the various diagram types Rational Rose (IBM.. M

17. GRASP: Designing Objects with Responsibilities

THE OBJECT-ORIENTED DESIGN PROCESS AND DESIGN AXIOMS (CH -9)

CSE 70 Final Exam Fall 2009

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Design Pattern and Software Architecture: IV. Design Pattern

Magento Technical Guidelines

Compositional Model Based Software Development

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of

UNIT V *********************************************************************************************

17.11 Bean Rules persistent

CS342: Software Design. November 21, 2017

Java 8 Programming for OO Experienced Developers

SDC Design patterns GoF

Object-Oriented Systems Analysis and Design Using UML

Design Patterns. Design Patterns 1. Outline. Design Patterns. Bicycles Simulator 10/26/2011. Commonly recurring patterns of OO design

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

CHAPTER 1. Topic: UML Overview. CHAPTER 1: Topic 1. Topic: UML Overview

Topic : Object Oriented Design Principles

An Introduction To Object Modeling System Concept for Object Modeling The Overall View Components of UML Diagram

Introduction to Object-Oriented Programming

Chapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures

Index. : (colon), 80 <<>> (guillemets), 34, 56

Object-Oriented Design

2 UML for OOAD. 2.1 What is UML? 2.2 Classes in UML 2.3 Relations in UML 2.4 Static and Dynamic Design with UML. UML for OOAD Stefan Kluth 1

Exam Questions. Object-Oriented Design, IV1350. Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E

Building custom components IAT351

Glossary. For Introduction to Programming Using Python By Y. Daniel Liang

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Basic Structural Modeling. Copyright Joey Paquet,

Chapter 10 Object-Oriented Design Principles

Software Design and Analysis CSCI 2040

OBJECT ORIENTED ANALYSIS AND DESIGN SYLLABUS

Outline of UML and Unified Process. Object Oriented Analysis/Design/Programming UML1.5. Koichiro Ochimizu, JAIST. UML&UP outline 1.

CPS 506 Comparative Programming Languages. Programming Language

Chapter 6 Introduction to Defining Classes

OMG Modeling Glossary B

1 Software Architecture

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Composite Pattern. IV.4 Structural Pattern

Principles of Software Construction: Objects, Design, and Concurrency. Assigning Responsibilities to Objects. toad. Jonathan Aldrich Charlie Garrod

UML Modeling I. Instructor: Yongjie Zheng September 3, CS 490MT/5555 Software Methods and Tools

Review Software Engineering October, 7, Adrian Iftene

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

Lecture 2 and 3: Fundamental Object-Oriented Concepts Kenneth M. Anderson

Transcription:

Object-Oriented Design Lecture 14: Design Workflow Department of Computer Engineering Sharif University of Technology 1

UP iterations and workflow Workflows Requirements Analysis Phases Inception Elaboration Construction Transition An iteration in the elaboration phase Design Implementation Test Prelim inary Ite ration (s) iter. #1 iter. #2 iter. #n iter. #n+1 iter. #n+2 iter. #m iter. #m +1 Iterations Sharif University of Technology 2

Design Workflow The design workflow is about determining how the functionality specified in the analysis model will be implemented. The design workflow is the primary modeling activity in the last part of the Elaboration phase and the first part of the Construction phase. The design model contains: design subsystems; design classes; interfaces; use case realizations-design; a deployment diagram (first-cut). Sharif University of Technology 3

Trace Relationships Sharif University of Technology 4

Design Workflow: Design a Class The Design Workflow consists of the following activities: Architectural Design Design a Use Case Design a Class Design a Subsystem Sharif University of Technology 5

Design Classes Design classes are the building blocks of the design model. Design classes are developed during the USDP activity Design a Class. Design classes are classes whose specifications have been completed to such a degree that they can be implemented. Sharif University of Technology 6

Design Classes: Sources Design classes come from two sources: the problem domain: a refinement of analysis classes; one analysis class may become one or more design classes; the solution domain: utility class libraries; middleware; GUI libraries; reusable components; implementation-specific details. Sharif University of Technology 7

Design Classes: Sources Most of the classes in the Analysis class diagram can be found in the Design class diagram as well. some of the differences between the analysis and the design class diagrams: Controllers Objects to implement associations and aggregations Objects for performance, persistence, concurrency, interface to other subsystems, etc. Collections for finding objects based on a key value (that comes from the UI, for example). Sharif University of Technology 8

Design Classes: Sources Some of the classes in the analysis class diagram may not show up in the design They may be outside the system The may become attributes of other objects because they don t have enough behavior of their own. What looked like inheritance at analysis time might be better implemented another way (e.g., as flag attributes) in the design. Sharif University of Technology 9

Design Classes: Sources Sharif University of Technology 10

Design Classes: Anatomy Design classes have complete specifications: complete set of attributes including: name; type; default value when appropriate; visibility; operations: name; names and types of all parameters; optional parameter values if appropriate; return type; visibility. Sharif University of Technology 11

Design Classes: Anatomy The Trace relationship is a specialization of a Dependency connecting model elements or sets of elements that represent the same concept across models Traces are often used to track requirements and model changes Sharif University of Technology 12

Design Classes: Well-formedness The public operations of the class define a contract with its clients. Completeness - the class does no less than its clients may reasonably expect. Sufficiency - the class does no more than its clients may reasonably expect. Primitiveness - services should be simple, atomic, and unique. Sharif University of Technology 13

Design Classes: Well-formedness (Contd.) High cohesion: each class should embody a single, well-defined abstract concept; all the operations should support the intent of the class. Low coupling: a class should be coupled to just enough other classes to fulfill its responsibilities; only couple two classes when there is a true semantic relationship between them; avoid coupling classes just to reuse some code. Sharif University of Technology 14

Inheritance Only use inheritance when there is a clear "is a" relationship between two classes or to reuse code. Disadvantages: it is the strongest possible coupling between two classes; encapsulation is weak within an inheritance hierarchy, leading to the "fragile base class" problem: changes in the base class ripple down the hierarchy; very inflexible in most languages - the relationship is decided at compile time and fixed at runtime. Sharif University of Technology 15

fragile base class The base class is the class you are inheriting from Often called fragile because changes to this class can have unexpected results in the classes that inherit from it. A best practice to avoid label all classes as final unless you are specifically intending to inherit from them. For those to intend to inherit from, design them as if you were designing an API hide all the implementation details be strict about what you emit and careful about what you accept document the expected behaviour of the class in detail. Sharif University of Technology 16

Inheritance and Aggregation There are two schools of thought on how to best extend, enhance, and reuse code in an object-oriented system: Inheritance: extend the functionality of a class by creating a subclass. Override superclass members in the subclasses to provide new functionality. Aggregation: create new functionality by taking other classes and combining them into a new class. Attach an common interface to this new class for interoperability with other code. Sharif University of Technology 17

Inheritance and Aggregation we need inheritance or aggregation? If The new class is more or less as the original class, Use inheritance. The new class is now a subclass of the original class. If the new class must have the original class, Use aggregation. The new class has now the original class as a member. Sharif University of Technology 18

Inheritance and Aggregation If we have used inheritance but we only use part of the interface Or we are forced to override a lot of functionality to keep the correlation logical Then we have a big nasty smell that indicates that we had to use aggregation. If we have used aggregation but we find out we need to copy almost all of the functionality Then we have a smell that points in the direction of inheritance. Sharif University of Technology 19

Inheritance and Aggregation We should use aggregation if part of the interface is not used or has to be changed to avoid an illogical situation. We only need to use inheritance if we need almost all of the functionality without major changes. when in doubt, use Aggregation. The case that we have an class that needs part of the functionality split the original class in a root class and a sub class let the new class inherit from the root class But take care not to create an illogical separation. Sharif University of Technology 20

Inheritance and Aggregation At the beginning of GOF they state: "Favor object composition over class inheritance." Inheritance should be used only if the relationship is-a is unequivocally maintained throughout the lifetime of the objects otherwise, aggregation is the best choice role is often confused with an is-a relationship. For example: given the class Employee not a good idea to model the roles an employee can play (such as a manager or a cashier) by inheritance if these roles change Sharif University of Technology 21

Inheritance and Aggregation Subclasses should always represent "is kind of" rather than "is role played by" - always use aggregation to represent "is role played by". Sharif University of Technology 22

Multiple Inheritance Multiple inheritance allows a class to have more than one parent. Of all the common OO languages only C++ has multiple inheritance. Design guidelines: the multiple parent classes must all be semantically disjoint; there must be an "is kind of" relationship between a class and all of its parents; the substitutability principle must apply to the class and its parents; the parents should themselves have no parent in common; use mixins - a mixin is a simple class designed to be mixed in with others in multiple inheritance; this is a safe and powerful idiom. Sharif University of Technology 23

Inheritance versus Interface Realization Inheritance: you get interface - the public operations; you get implementation - the attributes, associations, protected and private members. Interface realization: you only get interface. Use inheritance when you want to inherit some implementation. Use interface realization when you want to define a contract. Sharif University of Technology 24

Inheritance versus Interface Realization Inheritance describes an is-a relationship. Implementing an interface describes a can-do relationship. general recommendations are as follows: Do favor defining classes over interfaces. Do use abstract classes instead of interfaces to decouple the contract from implementations. Abstract classes, if defined correctly, allow for the same degree of decoupling between contract and implementation. Do define an interface if you need to provide a polymorphic hierarchy of value types. Consider defining interfaces to achieve a similar effect to that of multiple inheritance. Sharif University of Technology 25

Templates Templates allow you to "parameterize" a type create a template by defining a type in terms of formal parameters; instantiate the template by binding specific values for the parameters. Of all the commonly used OO languages, only C++ and Java currently support templates. Explicit binding uses a dependency stereotyped «bind»: show the actual values on the relationship; each template instantiation can be named. Sharif University of Technology 26

Templates: Example Sharif University of Technology 27

Templates: Implicit Binding Implicit binding: specify the actual values on the class inside angle brackets ; template instantiations cannot be named - names are constructed from the template name and the argument list. Sharif University of Technology 28

Nested Classes Defined as a class inside another class. The nested class exists in the namespace of the outer class - only the outer class can create and use instances of the nested class. Nested classes are known as inner classes in Java, and are used extensively for event handling in GUI classes. Sharif University of Technology 29

Reference Arlow, J., Neustadt, I., UML 2 and the Unified Process: Practical Object- Oriented Analysis and Design, 2 nd Ed. Addison-Wesley, 2005. Sharif University of Technology 30