Software Modelling and Design Note Sheet
Software Modelling and Design Note Sheet
3 Actor Types: Primary (has goals fulfilled by SuD, drive the Static Design Model: Representation of software objects
use case), Supporting (provides service to SuD), Offstage defining class names, attributes and method signatures.
(has interest in behavior of use case) Names and associations are inspired by domain model, to
Useful Use Case Tests: Boss Test (would boss be happy if reduce the Representational Gap (between how
use case was completed in a day’s work), Elementary stakeholders conceive the domain and its representation in
Business Process Test (Performed by one person, in one software – easier to comprehend and to update to
place/time, in response to business event which adds corresponding changes in the domain)
measurable business value and leaves data in consistent Responsibility Driven Design: focus on assigning
state), size test (task is seldom a single action/step; fully responsibilities to software objects. Responsibility:
dressed often require 3 – 10 pages) obligations or behaviours of an object in terms of its role.
Notation: Main success scenario first with N, alternative Two types: Knowing (knowledge of private/encapsulated
scenarios next using letters Nx. Use *x alternative that could data, related objects, things it can derive or calculate).
happen at any point. Doing (doing something itself – creating object or
When partial behaviour common across multiple use cases, calculating something, initiating action in other objects,
use <<include>> and refactor into a subfunction use case. controlling and coordinating activities in other objects). Can
When adding new extensions or conditional steps, use be implemented in collaboration with other objects.
<<extend>> (primary actor interacts with base case which is Dynamic Design Model: Representation of how objects
complete without extension, extension relies on base case) interact via messages.
Diagram: primary actors on left, supporting on right Notation: <<destroy>> -> X; create(constructorArgs)->X (at
(computer systems use box), limit use cases to user-goal height of creation); loop and alt frames can be placed with
level. [guard] and action boxes with plain text placed over lifeline
of object to which it applies. sd and ref and be used to
DOMAIN MODELLING: OO Analysis creates description of define/refer to sub-diagrams (must cover the same lifelines
the problem domain from perspective of objects. Shows and have same name.
conceptual classes, attributes and associations in the Visibility: The scope or ability of an object A to see/access
problem domain. another object B. Four ways (B attribute of A, B parameter
Conceptual Class: representation of real-situation of method in A, B local object in method of A, B has some
conceptual classes (idea/thing/object; {symbol: represents form of global visibility)
class; intension: definition of class; extension: set of Communication vs Sequence Diagram: More layout
examples for which it applies}) options, clearly shows relationships between object
Description Class: contains information that describes instances, combines scenarios to provide complete picture.
something else, used when a group of items share a But More difficult to see message sequencing, fewer
description, and items need to be described even when notation options for expressing message patterns.
there are currently no examples. Map Design to Code: Begin at least coupled classes (so that
Class Identification: use existing models for common more coupled classes can be defined in terms of already
domain problems, use a category list, perform noun mapped classes). For multiplicities, choose the appropriate
extraction. collection that supports requirements (key-based lookup:
Association: relationship that indicates Map, growing ordered list: List). If it implements an
meaningful/interesting connections b/w classes. Include interface declare in terms of the interface.
ones which are significant in domain, knowledge of which
needs to be preserved, or are derived from common GRASP: set of patterns/principles of assigning
associations table. responsibilities to objects. (captures and facilitates reuse of
Generalisation: Define a superclass (with general concept) expertise to make accessible to non-experts, improves
and subclass (with specialized concept), related by set understanding and communication by providing common
membership, to reduce repeated information and improve language.
comprehension. Creator: Who should be responsible for creating a new
Attribute: A logical data value of an object, included in instance of class A? (Doing Responsibility)
classes when requirements imply need to remember Assign class B responsibility to create instances of class A if:
information. Use (/attribute for derived attribute). B ‘contains’ or compositely aggregates A; B records A; B
Use subclass when there are additional attributes of closely uses A; B has the initialising data for A.
interest, or operated on/manipulated/reacted to differently Note: This is useful for low maintenance and high reuse
(else have a type attribute). potential (low coupling). If creation of objects is complex
SSD: Visualisation of system events that external actors (conditionally creating instance from a family of similar
generate and possible inter-system events, showing their classes based on external property) then delegate creation
order for a particular scenario. Captures dynamic context, to (concrete/abstract) Factory helper class.
treating system as black box with reference to domain Information Expert: Given object X, which responsibilities
model. (doing/knowing) can be assigned to X?
Assign responsibility to X if X has the information to fulfill
DESIGN MODELS: a conceptual solution to a problem that that responsibility.
meets requirements, emphasizing defining software objects Note: Sometimes produces undesirable design due to
and their collaboration: structure and connectedness (levels problems with the resulting dependencies.
and architecture), interfaces (methods, datatypes and
Low Coupling: How to support low dependency, low change impact on other elements?
impact, and increased reuse? Identify points of known or predicted variation or instability
Coupling: how strongly one element is connected to (has and assign responsibilities to create a stable interface
knowledge of, or relies on) other elements around them (in the general access sense of ‘interface’).
High Coupling: Hard to understand in isolation, hard to Notes: Two types of points of change: Variation Points
reuse, one change impacts many classes (high impact (variation existing within the current system requirements),
change) Evolution Points (speculative variations that may arise in the
Assign responsibilities to avoid unnecessary coupling and to future). PV is a root principle motivating most patterns in
keep coupling low. Use this to evaluate alternatives. Low design, equivalent to Open Closed principle. However cost
coupling minimises dependencies, making the system more of future proofing at evolution points can outweigh the
maintainable and improving reusability of code. benefits.
Note: High coupling with stable and well understood
elements (Standard Java Libraries) is generally OK. TEST DRIVEN DEVELOPMENT: Test code written before the
High Cohesion: How to keep objects focused, code it will test (acceptance tests at the start of iteration,
understandable, and manageable, and as a side unit tests before the corresponding class), ensure tests are
effect, support Low Coupling? passed before proceeding.
Cohesion: How strongly related/focussed the Pros: Tests actually get written, programmer satisfaction
responsibilities of an element are. leads to more consistent test writing, clarification of
Assign responsibilities to avoid unnecessarily reducing detailed interface and behaviour, proven & repeatable &
cohesion. Use to evaluate alternatives. Improves ease of automated verification, gives developers confidence to
comprehension, simplifies maintainability and make changes.
enhancement. Refactoring: Structured, disciplined method for rewriting or
Note: sometimes low cohesion is necessary for non- restricting existing code without changing its external
functional requirements (performance reasons). behaviour, through a series of small behaviour preserving
Controller: Which first object beyond the UI layer receives transformations after each of which unit tests can be
and coordinates a system operation? redone to prevent regression/failure.
Assign responsibility to one of: STATE MACHINE DIAGRAM: A behaviour model that
[i] Façade controller: representing the overall system. captures the dynamic behaviour of an object in terms of
[ii] Use case or session controller: representing a particular states (condition of object at given moment), events
use case scenario dealing with an event. (significant/noteworthy occurrence), and state transitions
Note: If controller is bloated with low cohesion and too (directed relationship between two states corresponding to
many responsibilities: add more session controllers, or an event). They should be used for state dependent objects
delegate responsibilities if it is violating information expert. (whose response to an event depends on the object’s state,
Indirection: Where to assign a responsibility to avoid direct rather than state independent (/wrt an event) objects)
coupling between two or more things (to maintain low Nested States: inherit the transitions from its superstate,
coupling and increase reuse potential)? and must have their initial state indicated.
Assign the responsibility to an intermediate object to Choice Pseudostate: realises a dynamic conditional branch,
mediate between the other components or services so that evaluating guards of the triggers of its outgoing transitions
they are not directly coupled. and selects only one.
Note: can decrease performance.
Pure Fabrication: Which object should have responsibility GOF DESIGN PATTERNS: three categories of pattern:
when you do not want to violate High-Cohesion and Low- Creational (abstract the process of object instantiation),
Coupling, but solutions offered by other are not Structural (combine classes and objects to form larger
appropriate? structures, describe ways to define relationships between
Assign a highly cohesive set of responsibilities to an artificial classes),
or convenience class that does not represent a problem Behavioural (most specifically concerned with
domain concept. communication/interaction between objects).
Note: Do not overuse, since it increases representational Façade: Require a common, unified interface to a disparate
gap and can adversely affect coupling by increasing set of implementations or interfaces—such as within a
dependencies. subsystem. There may be undesirable coupling to many
Polymorphism: How to handle alternatives based on type objects in the subsystem, or the implementation of the
(conditional variation), and create pluggable software subsystem may change.
components? Define a single point of contact with the subsystem, a
When related alternatives or behaviours vary by type, façade object which wraps the subsystem, and represents a
assign the responsibility for the behaviour to the types for single unified interface responsible for collaborating with
which it varies using polymorphic operation (with a the subsystem components.
common stable interface) Example: need a rule engine subsystem with a currently
Note: This makes the design easily extendible to handle unknown implementation (desire pluggability) in a POS
new variations. Can result in unnecessary effort if applied to system.
speculative points of future variation which are improbable. Decorator: How to dynamically add behaviour or state to
Protected Variations: How to design objects, subsystems, individual objects at run-time without changing the
and systems so that the variations or interface presented to the client?
instability in these elements does not have an undesirable Encapsulate the original concrete object inside an abstract
wrapper interface, and let the decorators (which contain Define classes for composite and atomic objects so that
the dynamic behaviours) also implement this abstract they implement the same interface. If there are multiple
interface. Then let the interface use recursive composition conflicting strategies these can be handled in a singleton
to allow unlimited decorator layers to be added to each composite strategy factory.
core object: