Part 2: Building On the Basics

Slides:



Advertisements
Similar presentations
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes (continued)
Advertisements

Essentials of interaction diagrams Lecture 23 & 24.
Essentials of state and activity diagram Lecture 24.
Chapter 9 Domain Models. Domain Model in UML Class Diagram Notation A “visual dictionary”
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
Modelling Interactions and Behaviour. © Lethbridge/Laganière 2005 Chapter 8: Modelling Interactions and Behaviour2 Interaction Diagrams Interaction diagrams.
程建群 博士(Dr. Jason Cheng) 年03月
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
Chapter 6 Use Cases. Use Cases: –Text stories Some “actor” using system to achieve a goal –Used to discover and record requirements –Serve as input to.
1 Object-Oriented Analysis Use Case Driven. 2 The outline method for OOA 1.Identify object classes within the problem domain 2.Define the behaviour of.
1 Modeling interactions and behavior Lecturer Dr. Mai Fadel.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
UML-1 3. Capturing Requirements and Use Case Model.
Chapter Eleven Classes and Objects Programming with Microsoft Visual Basic th Edition.
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
CSE 240 Lecture 5. © Lethbridge/Laganière 2001 Chapter 5: Modelling with classes2 Overview Discuss Assignment 1 Discuss more of chapter 5, possibly finish.
Topic 4 - Database Design Unit 1 – Database Analysis and Design Advanced Higher Information Systems St Kentigern’s Academy.
Domain Model A representation of real-world conceptual classes in a problem domain. The core of object-oriented analysis They are NOT software objects.
Chapter 16 UML Class Diagrams.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
DOMAIN MODEL—PART 2: ATTRIBUTES BTS430 Systems Analysis and Design using UML.
ECDL ECDL is an important building block, equipping you with the digital skills needed to progress to further education and employment. ECDL teaches you.
Core LIMS Training: Project Management
Using Use Case Diagrams
Classes and their relationships
Processes and threads.
User-Written Functions
Chapter 9 Domain Models.
Chapter 5 System modeling
Working in the Forms Developer Environment
CMPE 280 Web UI Design and Development August 29 Class Meeting
Use Case Modeling - II Lecture # 27.
ATM OO Design and Implementation Case Study
State Machine Model.
State Diagram – Advanced Concepts
Chapter 5: Structural Modeling
SQL and SQL*Plus Interaction
Chapter 16 UML Class Diagrams.
UML for design: Class Diagrams ENGR 110 #
Yanal Alahmad Java Workshop Yanal Alahmad
Use Case Model.
Behavioral Design Patterns
Week 10: Object Modeling (1)Use Case Model
Objectives Identify the built-in data types in C++
CIS 764 Database Systems Engineering
CS251 – Software Engineering Lectures 11 State Diagrams
Jira Workflows for Business Teams
Creating and Using Classes
Topics Introduction to File Input and Output
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
States.
Number and String Operations
Lecture 22 Inheritance Richard Gesick.
CIS16 Application Development Programming with Visual Basic
SAD ::: Spring 2018 Sabbir Muhammad Saleh
Programming with Microsoft Visual Basic 2008 Fourth Edition
This presentation document has been prepared by Vault Intelligence Limited (“Vault") and is intended for off line demonstration, presentation and educational.
Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy
Use Cases 1.
CIS 375 Bruce R. Maxim UM-Dearborn
Umple Mini-Course Part 1: The Basics
Introduction to C++ Programming
Using Use Case Diagrams
States.
Tonga Institute of Higher Education
Welcome 1 This is a document to explains the chosen concept to the animator. This will take you through a 5 section process to provide the necessary details.
CIS 375 Bruce R. Maxim UM-Dearborn
Running a Java Program using Blue Jay.
Topics Introduction to File Input and Output
Presentation transcript:

Part 2: Building On the Basics Umple Mini-Course Part 2: Building On the Basics Timothy C. Lethbridge, I.S.P, P.Eng. University of Ottawa, Canada tcl@eecs.uottawa.ca http://www.umple.org

Umple Mini-Course Part 2: Building on The Basics Derived attributes These generate a get method that is calculated. class Point    {       // Cartesian coordinates       Float x;       Float y;              // Polar coordinates       Float rho =  {Math.sqrt(Math.pow(getX(), 2) + Math.pow(getY(), 2))}       Float theta =  {Math.toDegrees(Math.atan2(getY(),getX()))}   }   Umple Mini-Course Part 2: Building on The Basics

Multi-Valued Attributes Limit their use. Associations are generally better. class Office {      Integer number;      Phone[] installedTelephones;   }       class Phone {     String digits;     String callerID;   }   Umple Mini-Course Part 2: Building on The Basics

Umple Mini-Course Part 2: Building on The Basics Keys Enable Umple to generate an equals() and a hashcode() method class Student { Integer id; name; key { id } } The user manual has a sports team example showing keys on associations too Note how this feature is not inherited from UML Umple Mini-Course Part 2: Building on The Basics

Umple Mini-Course Part 2: Building on The Basics Singleton Pattern Standard pattern to enable only a single instance of a class to be created. private constructor getInstance() method Declaring in Umple class University { singleton; name; } Umple Mini-Course Part 2: Building on The Basics

Umple Mini-Course Part 2: Building on The Basics Delegation Pattern A class calls a method in its ‘neighbour’ class RegularFlight { flightNumber; } Class SpecificFlight { * -- 1 RegularFlight; flightNumber = {getRegularFlight().getFullNumber()} Full details of this example in the user manual Umple Mini-Course Part 2: Building on The Basics

Umple Mini-Course Part 2: Building on The Basics Basic Constraints Shown in square brackets Code is added to the constructor and the set method class X {     Integer i;     [! (i == 10)]   }   We will see constraints later in state machines Umple Mini-Course Part 2: Building on The Basics

Tips for Building a Model from Requirements Skip the ahead to slides on state machines if time is short: Students read this at home Tips for Building a Model from Requirements Identify a first set of candidate classes Focus on the core 1-2 classes Add associations and attributes Find generalizations and apply patterns as needed Iterate for the other classes Then work on methods Iterate until the model is satisfactory Umple Mini-Course Part 2: Building on The Basics

Discovering Classes in Requirements Look at a source material such as a description of requirements Extract the nouns and noun phrases Eliminate nouns that: are redundant (same meaning) represent instances (e.g. specific people) are vague or highly general (e.g. ‘Object’) not needed in the application Pay attention to classes in a domain model that represent types of users or other actors They may or may not be needed Umple Mini-Course Part 2: Building on The Basics

Identifying Associations and Attributes Start with classes you think are most central and important Decide on the clear and obvious data it must contain and its relationships to other classes. Work outwards towards the classes that are less important. Avoid adding too many associations and attributes to a class A system is simpler if it manipulates less information Umple Mini-Course Part 2: Building on The Basics

Tips about identifying and specifying valid associations Specify the multiplicity at both ends Use role names if necessary Umple Mini-Course Part 2: Building on The Basics

Actions versus associations A common mistake: to represent actions as if they were associations Better: The borrow operation creates a Loan , and Bad, due to the use of associations the return operation sets the returnedDate that are actions attribute. Umple Mini-Course Part 2: Building on The Basics

Tips About Identifying valid attributes It is not good to have many duplicate attributes If a subset of a class’s attributes form a coherent group, then create a distinct class containing these attributes Umple Mini-Course Part 2: Building on The Basics

Umple Mini-Course Part 2: Building on The Basics Time for test 3 Click on the following link for Test 3 https://www.surveymonkey.com/r/Test3x-UmpleIsrael Umple Mini-Course Part 2: Building on The Basics

Basics of State Machines At any given point in time, the system is in one state. It will remain in this state until an event occurs that causes it to change state. A state is represented by a rounded rectangle containing the name of the state. Special states: A black circle represents the start state A circle with a ring around it represents an end state Umple Mini-Course Part 2: Building on The Basics

Garage Door State Machine class GarageDoor{ status { Open { buttonOrObstacle -> Closing; } Closing { buttonOrObstacle -> Opening; reachBottom -> Closed; Closed { Opening { buttonOrObstacle -> HalfOpen; reachTop -> Open; HalfOpen { Umple Mini-Course Part 2: Building on The Basics

Umple Mini-Course Part 2: Building on The Basics Events An occurrence that may trigger a change of state Modeled in Umple as generated methods that can be called Several states may be able to respond to the same event Umple Mini-Course Part 2: Building on The Basics

Umple Mini-Course Part 2: Building on The Basics Transitions A change of state in response to an event. It is considered to occur instantaneously. The label on each transition is the event that causes the change of state. Umple Mini-Course Part 2: Building on The Basics

State Diagrams – an Example with Conditional Transitions Umple Mini-Course Part 2: Building on The Basics

Actions in State Diagrams An action is a block of code that must be executed effectivey instantaneously When a particular transition is taken, Upon entry into a particular state, or Upon exit from a particular state An action should consume no noticeable amount of time Umple Mini-Course Part 2: Building on The Basics

State Machine for a Phone Line Umple Mini-Course Part 2: Building on The Basics

Umple for the Phone Line example class phone { state { onHook { startDialing -> dialling; incomingCall -> ringing; } ringing { pickUp -> communicating; otherPartyHangUp -> onHook; communicating { hangUp -> onHook; otherPartyHangUp -> waitForHook; putOnHold -> onHold; onHold { takeOffHold -> communicating; dialing { completeNumber -> waitingForConnection; hangUp -> onHook; } waitingForConnection { otherPartyPickUp -> communicating; timeOut -> onHook; waitForHook { Umple Mini-Course Part 2: Building on The Basics

In-Class Modeling Exercise Microwave oven system state machine Events include buttons, door opening, door closing, timer ending, etc. Umple Mini-Course Part 2: Building on The Basics

Umple Mini-Course Part 2: Building on The Basics Homework System for negotiating – major work task for after lecture 2 This system is to be used by negotiators, and mediators who are negotiating contracts. A contract has a list of sections, each with a number, e.g. 1. A section has a list of clauses, each with a second-level number, e.g. 2.4 A clause may have sub-clauses (and possibly even sub-sub- clauses) which may have numbers or letters too. We will call sections, clauses, and sub- clauses ‘items’. An item may have a title and always has some text.. Negotiation is done in a series of ‘rounds’ each of which has a start date and time. The groups negotiating are called ‘parties’. There are always two parties. At each round, each party may present some or all of the following Propose a set of changes (including re-proposing changes that were rejected/withdrawn) Agree to some set of changes that were previously proposed by the other party Reject some set of changes that were previously proposed by the other party Withdraw their own previous proposed changes that have not yet been accepted Umple Mini-Course Part 2: Building on The Basics

Umple Mini-Course Part 2: Building on The Basics Negotiating System - 2 A change may be A modification to an item Adding a new item. If a new item is proposed to be added it must be proposed to be inserted after a specific existing item, or as a subitem of an existing item, otherwise it goes at the end. Deleting an existing item. Negotiations go through the following states: They are ‘initiated’ when there is agreement to negotiate and the names of the people doing negotiating are entered in the system. Negotiations are ‘underway’ when there are outstanding proposals that remain ‘proposed’ (have not been ‘accepted’ or ‘withdrawn’). Negotiations reach ‘stalemate’ when there is no difference made after a negotiating round, or all proposals are ‘rejected’. Negotiations are ‘complete’ when all proposals are either ‘accepted’ or ‘withdrawn’ (i.e. there are no outstanding ‘rejected’ or ‘proposed’ changes). Umple Mini-Course Part 2: Building on The Basics

Umple Mini-Course Part 2: Building on The Basics Negotiating System - 3 A simple text reader can be used to read in the input. E.g. To propose adding a first item at the beginning P 0 First item The system would return a change id that could be used later for agreeing, rejecting and withdrawing -> C1 To agree to C! A C1 To display the current agreed contract D To display the current proposed changes C Extension to the system: A meditator can also ‘propose’ changes or ‘withdraw’ their own proposed changes. A change proposed by a mediator must be accepted by both parties to be fully ‘accepted’. Umple Mini-Course Part 2: Building on The Basics

How to Submit Your Negotiating System Add any necessary extra requirements or assumptions and document them as a text file Write the Umple code and compile it Get it to compile cleanly even if it doesn’t fully run Get as far as you can Put your name on files (as code comments) Generate a graphviz class and state diagram and save as files too Create a zip file with: Umple code + diagrams + text file Submit to the following link: http://bit.ly/2qqUYyK or https://www.dropbox.com/request/8cufWRaHStMjKWVQr6LV Umple Mini-Course Part 2: Building on The Basics

Do Activities and Concurrency A do activity executes In a separate thread Until Its method terminates, or The state needs to exit (killing the tread) Example uses: Outputting a stream (e.g. playing music) Monitoring something Running a motor while in the state Achieving concurrency, using multiple do activities Umple Mini-Course Part 4: Using the Full Power of Umple

Umple Mini-Course Part 4: Using the Full Power of Umple Active Objects These start in a separate thread as they are instantiated. Declared with the keyword active Umple Mini-Course Part 4: Using the Full Power of Umple

Default Threading in State Machines As discussed so far, code generated for state machines has the following behaviour: A single thread: Calls an event Executes the event (running any actions) Returns to the caller and continues This has two problems: If another thread calls the event at the same time they will ‘interfere’ There can be deadlocks if an action itself triggers an event Umple Mini-Course Part 4: Using the Full Power of Umple

Umple Mini-Course Part 4: Using the Full Power of Umple Queued State Machines Solve the threading problem: Callers can add events to a queue without blocking A separate thread takes items off the queue ‘as fast as it can’ and processes them Umple syntax: queued before the state machine declaration We will look at examples in the manual Umple Mini-Course Part 4: Using the Full Power of Umple

The Course Continues in Part 3 We will look at More advanced associations Separation of concerns using mixins, aspects and traits Generation of text using templates Nested state machines Auto and timed transitions Events with parameters State tables and simulations Pooling and queuing State machines in traits Database and Formal method generation Umple in Itself Umple Mini-Course Part 2: Building on The Basics