Some Simple Design Modeling Techniques State Transition Diagram
















- Slides: 16
Some Simple Design Modeling Techniques • State Transition Diagram to model the functional and execution (dynamic) aspects of the software system • Entity-Relation Diagram to model the data, data attributes and data relationships • UML’s Sequence Diagram to model object interactions.
State Transition Diagram for Detail Design • State Transition Diagrams were heavily used in – compiler design (strings that are acceptable) – automata theory (machine states) • State Transition diagram depicts a machine (system) composed of a (1) set of states, S, and (2)a set of alphabet (inputs) or stimulants, I, an (3) initial and (4) a final state and (5) a set of transition rules, R such that the following depicts the state transitions r (s 1, a) = s 2 – – – where s 1, s 2 are members of S (states) and a is a member of I r is a transition rule in R
Simple State Transition Design 0 1 0 S 1 So 1 - Define the initial and final states to be the same S 0. - The transition rules are: r 1: (S 0, 0) = S 1 r 2: (S 0, 1) = S 0 r 3: (S 1, 0) = S 1 r 4: (S 1, 1) = S 0 A system that will accept all strings of 0’s and 1’s that end with 1
Self-Exercise • Use State Transition diagram to depict a system that will accept strings made of 0’s and 1’s, but only those that have an even number of 0’s and 1’s.
One Answer 0 So S 1 0 1 1 0 S 3 0 S 2
A More Design Oriented Representation of A Process Flow Search again Start ‘Available’ Search flights to destination x by Flight Search Display all flights Check seat availability date Display all airlines with available seat Terminate search Note that this is a search only for flights with available seats, not a general flight search Terminate Flight Search function
Using State Transition Diagram for Design • Good for modeling the “states” and “transitions of states” of a system, of a component of a system, or a small segment of a component. • In order to use this modeling technique one has to think of: 1. 2. 3. 4. 5. All possible states: S’s All possible stimuli for change of state: I’s All the possible rules for transitions of states: R ( Ik, Si) -> Sj Initial or starting state of the system: S 0 Terminating state may be used as a tool to “test” out the component: e. g error path
Entity Relationship Diagram (ERD) • ERD was introduced as a technique to model Data Conceptual Model about 20 years ago, before introduction of OO, when it was realized that both data and functionality need to be considered together. • Description of Data Types: – Relationship among Data – Constraints on Relationship • From the ERD diagram, the Next step is Logical Database Design where ERD is mapped into Database Schema. • Besides DB, ERD May be used with OO techniques in designing Classes
Entity and Attributes • Entity is a “thing” which may be of : – Physical Existence such as cars, employees, lumber, etc. – Conceptual Existence such as company, project, payroll, etc. • Attribute is a property that describes the Entity (such as an employee may have attributes of sex, age, address, etc. ). • An attribute may be : – Simple or Composite : gender is simple where address is a composite – Single or Multi Valued: gender is single valued where car-color may be multi-valued (e. g. green-and-white is multi-color) – Stored or Derived: birth-date is stored where age may be derived (from today’s date minus birth-date) Also, an interesting design question. – Null : not applicable or unknown as opposed to blank
Example of Entity and Attributes - An Entity is represented as a rectangular box Employee - Attributes are represented as a) ovals attached to the entity or b) listed within the entity box (a) (b) Employee Address Street Sex City Name State Zip Employee -Name -Sex -Address - Street - City - State - Zip
Further Descriptions of Entities and Attributes Entity Type represents a set of entities that have the same attributes. Note the similarity between Entity Type and Class and each entity and each object - employee 1(Joe, male, 43) - employee 2(Tom, male, 32). . Entity Type is “Employee” “Key” Attribute is an attribute which has a unique value and may be used as search index, and is represented with an underline. Employee Name Address Employee Number
Entity Relationships • A Relationship, R, is an association between or among Entity Types. – Employee R Project – where R may be defined as “work on” • Degree of Relationship defines the number of participating entity types for that relationship. – Binary : Employee “works for” Customer Employee Works for Customer – Ternary : Equipment “supplies” Project and Employee “supplies” Project Equipment Supplies Employee Project
Constraints on Relationship • Constraints are “limitations” put on the entities that participate in a relationship: – Cardinality – Modality • Cardinality: specifies the number of occurrences of one entity that can be related to the number of occurrences of another entity: • one-to-one : ( person to seat) where each person occupies a seat and each seat is occupied by one person • one-to-many : (artist to paintings) where each artist can paint many paintings but each painting is painted by one artist • man-to-many : (students to classes) where many students are enrolled in a class and a student may be enrolled in many classes
Constraints on Relationship (cont. ) • Modality (or participation or existence) specifies whether the existence of an entity depends on its being related to another entity via the relationship: – Total : Every entity of the entity type participates in the relationship – Partial : Some of the entities of the entity type may participate in the relationship Author Actor write act Book Stage play Author, Actor (Partial) - because not all authors have written a book or actors played on stage Book, stage play (Total)- because every book is written by an author or every stage play is acted by actors
Cardinality and Modality Representation Author 1 Writes m Book Cardinality of 1 ( author) to (writes) many (books) Author (mandatory) Book (optional) Modality specifying that an author is mandatory for each book, but book is optional for author because some author never wrote a book
Represent Performance Requirement and Design (using UML Sequence Diagram as an example) Object 1 Object 2 Invokes an object 2 method Object 3 A Invokes an object 3 method (B-A)<2 sec. B Return This is the performance specification of 2 secs. in the detail design to satisfy some requirement