Object-Oriented Design. Module UFC016QM. and Programming. Objects and Classes. O-O Design Unit 2: Faculty of Computing, Engineering

Similar documents
The Object-Oriented Design Process

UML Is Not a Methodology

Darshan Institute of Engineering & Technology for Diploma Studies

Introduction to Unified Modelling Language (UML)

Object Oriented Software Development CIS Today: Object Oriented Analysis

(C) 2010 Pearson Education, Inc. All rights reserved. Dr. Marenglen Biba

Äriprotsesside modelleerimine ja automatiseerimine Loeng 7 Valdkonna mudel

Characterizing your Objects

Unified Modeling Language (UML)

Chapter 5: Structural Modeling

Domain Engineering And Variability In The Reuse-Driven Software Engineering Business.

Object-Oriented Design

ATM Use Cases. ID: CIS Title: Check Balance Description: Customer aims to know the balance in his/her account

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

HSBC Talking ATMs. Instructions and Guidance Handbook

Model-based Transition from Requirements to High-level Software Design

OO Analysis and Design with UML 2 and UP

Restricted Use Case Modeling Approach

06. Analysis Modeling

Object-Oriented Design

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

Lesson 06. Requirement Engineering Processes

02291: System Integration

Software Service Engineering

22/09/2012 INFO2110. Copyright Warning. Revision of class diagram. Overview. Purpose of class diagram. Generalization Relationship

Design First ITS Instructor Tool

Outline of Unified Process

VISHNU INSTITUTE OF TECHNOLOGY Vishnupur, BHIMAVARAM

Practical UML : A Hands-On Introduction for Developers

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

Chapter 1: Principles of Programming and Software Engineering

5 Object Oriented Analysis

For 100% Result Oriented IGNOU Coaching and Project Training Call CPD TM : ,

Practical UML - A Hands-On Introduction for Developers

Software Engineering I (02161)

CS 451 Software Engineering

Requirements document for an automated teller machine. network

CS350 Lecture 2 Requirements Engineering. Doo-Hwan Bae

Unified Modeling Language

Software Engineering I (02161)

02291: System Integration

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 5: Modelling with Classes

Object Oriented Methods with UML

Object-Oriented Analysis, Design and Implementation. Case Study Part II

Sofware Requirements Engineeing

Object Oriented Design. Program Design. Analysis Phase. Part 2. Analysis Design Implementation. Functional Specification

Practical Session 2: Use Cases and a Requirements Model.

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

Software component interactions and sequence diagrams

CS 2340 Objects and Design

CHAPTER 9 DESIGN ENGINEERING. Overview

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

Object-Oriented Design

Lecture 17 Engineering Design Resolution: Generating and Evaluating Architectures

OBJECT-ORIENTED MODELING AND DESIGN. Domain Analysis

LECTURE 3: SOFTWARE DESIGN. Software Engineering Mike Wooldridge

MechEng SE3 Lecture 7 Domain Modelling

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

System Name Software Architecture Description

Object-oriented development. Object-oriented Design. Objectives. Characteristics of OOD. Interacting objects. Topics covered

Object Oriented Analysis and Design: An Overview

1. (a) How does Object Oriented Programming facilitate the creation of reliable, reusable, extensible and adaptable code? [4]

Lecture Chapter 2 Software Development

Software Engineering - I

Introduction to Software Engineering: Analysis

SE 1: Software Requirements Specification and Analysis

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

1. Introduction to Object Oriented Software Development

References: Jacquie Barker,Beginning Java Objects; Martin Fowler,UML Distilled, 9/25/ UML

Storing Data in Objects

References: Jacquie Barker,Beginning Java Objects; Martin Fowler,UML Distilled, 1/13/ UML

Principles of Software Construction: Objects, Design, and Concurrency

Chapter 1: Programming Principles

Object-Oriented Systems Development: Using the Unified Modeling Language. Chapter 1: An Overview of Object- Oriented Systems Development

SHRI ANGALAMMAN COLLEGE OF ENGINEERING & TECHNOLOGY (An ISO 9001:2008 Certified Institution) SIRUGANOOR,TRICHY

Introduction to Software Engineering. 5. Modeling Objects and Classes

Specifying Structural Requirements

BCS Higher Education Qualifications. Diploma in IT. Object Oriented Programming Syllabus

CS504-Softwere Engineering -1 Solved Subjective Midterm Papers For Preparation of Midterm Exam

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

SWE 621: Software Modeling and Architectural Design. Lecture Notes on Software Design. Lecture 14 - Course Review

S T R U C T U R A L M O D E L I N G ( M O D E L I N G A S Y S T E M ' S L O G I C A L S T R U C T U R E U S I N G C L A S S E S A N D C L A S S D I A

Object-Oriented Systems Development: Using the Unified Modeling Language

Lab Manual For Software Engineering

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

Software Architectures. Lecture 6 (part 1)

Use C ases Cases 7/09

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

Summary of the course lectures

Header Description: This use case describes how the ATM user withdraws cash from the ATM.

The Software Design Process. CSCE 315 Programming Studio, Fall 2017 Tanzir Ahmed

Software Engineering with Objects and Components Open Issues and Course Summary

Today s Topic. Lecture 5. What is UML? Why Use UML. UML Diagrams. Introduction to UML. What is UML Why use UML? UML Diagrams

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

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

user.book Page 45 Friday, April 8, :05 AM Part 2 BASIC STRUCTURAL MODELING

Object-Oriented Software Engineering. Chapter 2: Review of Object Orientation

Importance of Rational ROSE in Software Development Process Models

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

Modelling with Classes. CITS1220 Software Engineering

Transcription:

Module UFC016QM Object-Oriented Design and Programming O-O Design Unit 2: Objects and Classes Faculty of Computing, Engineering and Mathematical Sciences

Schedule Quick recap on Use Case diagrams UWE Flix What are Objects and Classes? How to identify them. Class / Responsibility / Collaboration (CRC) Encapsulation, Abstraction, Cohesion, Coupling, Stereotypes UML diagrams and notation

UML Use Case Diagram Add Film Remove Film Cinema Manager Add Showing Cinema Booking System

What is a Use Case? Collection of related scenarios. Textual narrative Unit of interaction between actor and system what the system does, not how Sequence / Flow yielding result of value to actor* Basis of system scope, construction and testing

How do Actors interact with system? Amend Widget Details Sequence ACTOR Actor requests to search for Widget Actor chooses Widget Actor amends Widget Details SYSTEM System displays list of potential Widgets System provides Widget Details System updates Widget Details ping-pong interaction

Use Case Recap There is a lot of variation as far as how you might describe the contents of a use case; the UML does not specify any standard. [Fowler] This can be a problem, particularly: Actors, level of detail Depends upon risk the greater the risk the greater the detail

Actors Actors do not need to be human e.g. external system. Some people refer to all external systems as actors, others just some or none at all

How do I Identify Use Cases? Identify candidate system actors identify candidate use cases Refine and scope units of interaction (use cases) start point (look for actor and initial event) end point (look for beneficial result the goal - for actor)

Some Rules Use include when repeating in two or more separate use cases. Use generalization when casually describing variation on normal behaviour. Use extend when describing variation on normal behaviour in a more controlled form. [Fowler]

Key Points There is a lot of variation as far as how you might describe the contents of a use case; the UML does not specify any standard. [Fowler] Risk = level of detail Think and justify

Recap - a system made up of objects... Computer System Object Function Data

What is an Object? An object is the primitive element of object-orientation. An Object will: provide services to other objects via methods (or functions, or operations!) exist at runtime encapsulate data

Object terminology Function 1 Function 4 Function 6 Data Function 2 Function 7 Function 3 Function 5 Function 8 Implementation of operation also known as: Method Object data values also known as: Attributes or Properties

So what about classes? A blueprint for an object. A class defines an objects generic behaviour and the type of data it may store. Exist in code An instance of a class = an object

Instances of Classes Objects that behave in a manner specified by a class are called instances of that class. [Brock] Instances of the same class provide the exactly the same services* Data held in instances of the same class will typically vary. *Subject to data not controlling flow

Classes & Objects Class - the template for all instances (or objects!) Brown 123456 150 1999 Query Balance Check Pin Name Account # Balance Pin # Show Details Deposit Withdraw Objects

Classes & Objects Classes - * found in model, code * reveal static semantics * reveal structure & architecture of system Objects - * found in the machine memory at runtime (and model, code) * reveal behaviour of system * reveal dynamic semantics of system

Class Design Object - Real

Encapsulation Send a Message Client objects see a service revealed as an operation Client objects cannot see encapsulated data! Function 1 Function 4 Data Function 6 Function 2 Function 7 Function 3 Function 5 Function 8

What is Encapsulation? Information-hiding What I can do NOT how I do it Bank Account example Achieved by: Public service (methods that other objects can call) Private data

Bank Account Example Directly manipulating balance would cause failure but data encapsulation won t! Evil Object Account Object Function - 50 AddFunds Data 100

Benefits of Encapsulation Promotes maintenance Code changes can be made independently Increases usability Public interfaces Promotes coherence of object does only one thing, and does it well controls of visibility of operations & state data is private / not accessible

Collaboration Objects must collaborate Client-Server style requests Designing for collaborations create reusable components Different types of collaboration relationships: is-part-of, has-knowledge-of, and depends-upon

Objects Collaborate With Other Objects Get Total Price Get Cost Shopping Basket Get Cost Computer System War & Peace Book 19.99 Get Cost Best Ever Hits 2002 CD 17.99 Mission Impossible Impossible DVD DVD 29.99

Finding Collaborations 1. Can the class carry out the assigned responsibility on its own? 2. If not then what does it need? 3. Which other class can meet this need? [Brock] Helps identify misplaced responsibilities.

Object coupling & cohesion Tight Coupling Loose Coupling Objects of low cohesion are not sure what they do... Cohesive objects do one thing, and only one thing, well!

Definitions Cohesion 1. sticking or working together the state or condition of joining or working together to form a united whole, or the tendency to do this

Coupling and Cohesion Loose coupling, but not always, find a happy medium! Encapsulation enables a class to be highly cohesive (clear purpose) Highly cohesive classes have clearly defined relationships with other classes A collection of tightly formed objects can be grouped together to form a package

Where do classes come from? Analyse Nouns (in use cases etc.) Analyse Nouns (in use cases etc.) Analyse Nouns (in use cases etc.) ABSTRACTION Cluster Classes from Objects Cluster Classes from Objects Cluster Classes from Objects Whole Objects / Component Parts Whole Objects / Component Parts Whole Objects / Component Parts Reject Synonyms Reject Synonyms Reject Synonyms Evaluate Scope Evaluate Scope Evaluate Scope

Identifying Classes Many ways to do this but start by Select nouns from requirements Discard obvious Then (Recursive process) Physical objects Careful with adjectives You won t get all the classes initially.

Class Responsibility Collaboration Once you have the classes you need to identify what they do (responsibility) and who they do it with (collaboration) Validates class selection Again a recursive process Work in groups when possible

Class Responsibility Collaboration (CRC) Class Name: what am I? Responsibilities: Collaborations: What do I know? What do I Do? What do I Decide? Who do I interact with? A set of responsibilities is what a class does - its stereotypical behaviour

Example ATM - Brock Initial look through the requirements produces the following classes: Automated Teller Machine ATM Balance Cash dispenser Many more Customer Deposit Money dispenser slot Transaction Printer Withdrawal

Elimination Remove classes that are actually the same: ATM = Automated Teller Machine Normal keypad = Numeric keypad Personal Identification Number = PIN Printer = Receipt Printer

Outside of System Eliminate classes outside of system scope, e.g. Authorized bank employee Bank Card Deposit Envelope Receipt

Keep Physical! For example: Display Screen Deposit Slot Numeric Key Receipt Printer Cancel Key

Candidate Classes Arrive at Candidate Classes: Account ATM Balance Inquiry Bank Card Reader Cancel Key Cash dispenser

From Brock Pages 51-60

Quick Recap Objects are instances of classes Classes = blueprints of objects Classes exist in code, objects exist at runtime Encapsulation means private data and a public interface Encapsulation enables a class to be highly cohesive (clear purpose)

UML Notation - the object Object Name Class Name Smith:Customer NB (1): underline font indicates an instance! NB (2): Class and Object are NOT the same thing!

UML Notation - the class Stereotype Class Name Attributes Operations <<business>> Customer Date of Birth Address Get Birthday() Change Address()

Stereotypes some examples <<business>> class Abstraction derived from business concept in problem domain Name Address Locate «business» Customer <<interface>> class Abstraction representing a single point of entry to component or device, offering a collection of services «interface» Calendar ScheduleTask AddEvent

Further stereotype examples <<Controller>> Decision maker, state maintainer <<Information Holder>> Knows certain facts e.g. about concepts, rules <<Structurer>> Organises and presents objects e.g. lists, collections, stacks etc. <<Coordinator>> Reacts to events, delegates

Summary Objects encapsulated unit cohesion & coupling important during collaboration Classes abstractly classified from business domain concepts found in use cases CRC useful for validating candidate classes Stereotypes useful for intent of class

Tutorial - Identify candidate classes Divide into pairs Refer to the UweFlix Cinema Booking System case study, and your use cases Identify candidate classes using the CRC technique Identify significant attributes for your candidate classes Create a class diagram in the Poseidon tool

Test your knowledge Why are loosely coupled collaborations a good thing? Explain how clear class responsibilities lead to cohesive classes. Critically assess the analysis and design value of stereotypes.

Next Week Class relationships UML package (class) diagrams Dependency Association Aggregation Read chapter on class diagrams in Fowler

References [Brock] Designing Object-Orientated Software Wirfs-Brock et al (The blue book!) [Fowler] UML Distilled 2 nd Edition