π Lecture 17 β Identify Structures and Establishing Responsibilities
π Overview: This lecture focuses on two critical activities in object-oriented analysis: identifying structures (generalization-specialization and whole-part) and establishing object responsibilities (attributes, collaborations, and services). These steps transform a raw list of candidate objects into a well-organized, semantically rich domain model that captures both what objects know and what they do.
ποΈ Topics Covered
This lecture covers the identification of Gen-Spec and Whole-Part structures, then moves into establishing object responsibilities through three steps: defining attributes (what I know), showing collaborations (who I know), and defining services (what I do). For each step, specific guidelines and criteria are provided along with type-specific considerations for actors, participants, places, transactions, line items, and items.
π Lecture Summary
Identify Structures
A structure is a manner of organization which expresses a semantically strong organization within the problem domain. There are two types of structures: Generalization-Specialization (Gen-Spec) and Whole-Part. This activity identifies these structures in two steps:
π Definition β Structure: A manner of organization expressing a semantically strong organization within the problem domain.
Step 1: Identify Gen-Spec Structures (Hierarchy) Consider each class you have identified as a specialization and then look for its generalization, and vice versa.
Step 2: Identify Whole-Part Structures (Aggregations) For each object you have identified, consider it as a whole and then try to find out its parts β objects that make up this object.
Define Attributes - What I Know?
After identifying objects, the first thing to consider is their attributes, i.e., what it knows. For each object, include the attributes that come to mind when you first think about the object. The criteria for inclusion: an attribute should be included if the system needs to know its value and it cannot get it any other way. Do not add an attribute for an association or aggregation. Examples of attributes include: number, name, address, date, time, operational state, phone, status, threshold, type.
π‘ Why this matters: Proper attribute selection is critical because it directly impacts data integrity and system efficiency.
Type-specific attribute considerations:
- For actors: name, address, phone
- For participants: number, date and time, password, authorization level
- For place/location: number, name, address (perhaps latitude, longitude, altitude)
- For transaction: number, date, time, status
- For line item: quantity, status
- For item: name, description, dimension, size, UPC, weight
Issues to be aware of while defining attributes:
- An attribute that varies over time (e.g., price of an item) should be replaced by an additional class with an effective date and value
- An attribute that may have a number of values should be replaced by a new class and an object connection
- Replace βyes/noβ type attributes with βstatusβ type attributes for flexibility
- If there are classes with common attributes and generalization-specialization makes good sense, then add a generalization class and factor out the commonality
Show Collaborations (associations and aggregations) - Who I Know?
The second step in establishing each objectβs responsibility is to identify and show how this object collaborates with other objects, i.e., who it knows. These collaborations can be identified with the following 8 steps:
- For an actor, include an object connect to its participants (association)
- For a participant, include an object connection to its actor (already established) and its transactions (association)
- For a location, include object connections to objects that it can hold (association), to its part objects (aggregation), and to the transactions taking place at that location (association)
- For transactions, include object connections to its participants (already established), its line items (aggregation), and its immediate subsequent transaction (aggregation)
- For a transaction line item, include object connections to its transaction (already established), its item (association), a companion βitem descriptionβ object (association), and a subsequent line item (association)
- For an item, include object connections to transaction line item (already established), a companion βitem descriptionβ object (association)
- For a composite object, include object connections to its βpartβ object (aggregation)
- For all objects (including all of the above) select connecting objects to which the object sends a message (within one or more scenarios) to get some information or to answer a query about objects directly related to it (association)
Define Services - What I Do?
The third and last step in establishing each objectβs responsibility is to define what services does each object in the problem domain provide, i.e., what it does. Putting the right service with the right object is very important since any mistake in judgment will increase coupling and reduce cohesion. The verbs in your problem domain usually indicate some of the services required of the associated object.
π Key Principle: Keep data and action together for lower coupling and better cohesion. Software objects do things that the system is responsible to do with regard to that object. By putting the services with the attributes they work on results in lower coupling, stronger cohesion, and increased likelihood of reuse.
π The basic services done by all (such as get, set, create, initialize) are not shown in the object model.
While establishing services for an object, these fundamental questions should be asked:
- Why does the system need this object anyway?
- What useful questions can it answer?
- What useful action can it perform?
- What can this object do, based upon what it knows?
- What can this object do, based upon whom it knows?
- What calculations can it do?
- What ongoing monitoring could it do?
- What calculations across a collection could it make (letting each worker do its part)?
- What selections across a collection could it make (letting each worker do its part)?
Type-specific service considerations:
- For an actor consider: calculate for me, rate me, is <value>, rank participants, calculate over participants
- For a participant consider: calculate for me, rate me, is <value>, rank transactions, calculate over transactions
- For a place consider: calculate for me, rate me, is <value>, rank transactions, calculate over contents, calculate over container line items
- For a Transaction consider: calculate for me, rate me, is <value>, how many, how much, rank transaction line items, rank subsequent transactions, calculate over transaction line items, calculate over subsequent transactions
- For a line item consider: calculate for me, rate me
- For an item consider: calculate for me, rate me, is <value>, how many, how much, rank, calculate over specific items
β Key Takeaways
The lecture establishes a systematic three-step method for assigning responsibilities to objects: define attributes (what I know), show collaborations (who I know), and define services (what I do). For attributes, the critical rule is to include an attribute only if the system needs its value and cannot derive it otherwise, and to replace time-varying or multi-valued attributes with separate classes. For collaborations, eight specific step-by-step guidelines cover all standard object types from actors to composite objects. For services, the fundamental principle is to keep data and action together to achieve lower coupling and higher cohesion, with the basic CRUD services (get, set, create, initialize) being implied and not shown in the model. The type-specific checklists for all three responsibility areas provide concrete guidance that helps ensure no important attributes, collaborations, or services are overlooked.
π§ Quick Revision Questions
- What are the two types of structures identified during object-oriented analysis, and what is the focus of each type?
- What is the inclusion criterion for an attribute, and what should you do with attributes that vary over time or can have multiple values?
- What is the basic principle for assigning services to objects, and which services are typically not shown in the object model?
- List the eight steps for identifying collaborations (associations and aggregations) for different object types.
- What are the nine fundamental questions that should be asked when establishing services for an object?
π Lecture 20 β Interaction Diagrams β Depicting the Dynamic Behaviour of the System & Evaluating the Quality of an Object-Oriented Design
π Overview: This lecture explains how to model the dynamic behavior of an object-oriented system using interaction diagrams, specifically sequence and collaboration diagrams. It also covers how to evaluate the quality of an object-oriented design by analyzing encapsulation, delegation, coupling, and cohesion to create maintainable systems.
ποΈ Topics Covered
The lecture covers interaction diagrams for modeling dynamic behavior, including sequence diagrams with their notation, life lines, activation boxes, and message types (synchronous, asynchronous, create, destroy). It then covers collaboration diagrams as an alternative organizational view, comparing them with sequence diagrams. Finally, it addresses evaluating object-oriented design quality through centralized vs. distributed control, encapsulation, delegation, and reducing coupling.
π Lecture Summary
Interaction Diagrams β depicting the dynamic behaviour of the system
A series of diagrams can describe the dynamic behavior of an object-oriented system through messages exchanged among objects within a context to accomplish a purpose. This models how a use case is realized via a sequence of messages between objects.
The purpose of interaction diagrams is to:
- Model interactions between objects
- Assist in understanding how a system (a use case) actually works
- Verify that a use case description can be supported by existing classes
- Identify responsibilities/operations and assign them to classes
UML provides two mechanisms to document dynamic behavior: sequence diagrams (time-based view) and collaboration diagrams (organization-based view).
The Sequence Diagram
Sequence diagrams illustrate how objects interact, emphasizing time ordering of messages arranged in time sequence. They can model simple sequential flow, branching, iteration, recursion, and concurrency. The focus is on objects (and classes) and message exchanges among them. Objects are organized horizontally, and events on a vertical timeline.
The Notation
The notation uses:
- Boxes denote objects (or classes)
- Solid lines depict messages sent from one object to another
- Dotted lines are life lines representing the objectβs life during interaction
- Activation boxes on life lines show how long a particular message will be active
- Conditions can be shown in brackets before a message
π Definition β Life line: The dotted vertical line representing an object's existence during an interaction.
π Syntax for naming objects: [instanceName][:className] β Name classes consistently with your class diagram. Include instance names when objects are referred to in messages or when several objects of the same type exist.
π Example: In the library sequence diagram, member:LibraryMember sends mayBorrow() to itself, then if ok is true, sends borrow(book) to book:Book.
A message is represented by an arrow between life lines of two objects. For a message to be sent, an association must exist between those objects β either the receiver is in the global scope, local scope (method argument), or they are the same object. Self calls are also allowed.
Message Types
Sequence diagrams depict different types of messages:
Synchronous Messages β βCall eventsβ denoted by a full arrow. They represent nested flow of control (operation call). The caller waits for the called routine to complete before moving forward. Return values can be indicated optionally using a dashed arrow.
π Example: Object :A sends doYouUnderstand() to :B β :A is blocked until :B returns (optional) yes.
Guidelines for synchronous messages:
- Donβt model a return value when it is obvious (e.g.,
getTotal()) - Model a return value only when you need to refer to it elsewhere (e.g., as a parameter)
- Prefer modeling return values as part of a method invocation (e.g.,
ok = isValid())
Asynchronous Messages β βSignalsβ denoted by a half arrow. They do not block the caller. The caller does not wait for completion. This occurs in multi-threaded or multi-processing applications.
Asynchronous messages typically perform:
- Create a new thread
- Create a new object
- Communicate with a thread already running
Object Creation and Destruction β An object may create another via a <<create>> message and destroy via <<destroy>> message. An object may also destroy itself. Avoid modeling object destruction unless memory management is critical. The life line is affected accordingly.
π Example: Object :A sends <<destroy>> to :B, ending :B's life line. Similarly, :A may receive <<destroy>> to terminate itself.
Sequence diagrams and logical complexity
The golden principle: keep it small and simple. Diagrams are meant to make things clear. For simple conditional logic, add it to the diagram. For complex logic, draw separate diagrams like flowcharts.
Collaboration diagrams
Collaboration diagrams depict dynamic behavior with respect to organizational units (boundaries). Boundaries shape communication between system and outside world (e.g., user interface or other systems). The sequence of messages is determined by numbering (1, 2, 3, 4...), showing which operation calls which.
Collaboration diagrams have two components: objects and messages. They can show synchronous, asynchronous, create, and destroy messages using the same notation as sequence diagrams. Messages are numbered and can have loops.
π Example: In the course registration system: 1: set course info from Registrar to course form, 2: process, 3: add course to theManager, 4: <<create>> aCourse.
Comparing sequence & collaboration diagrams
- Sequence diagrams are best for seeing the flow of time
- Collaboration diagrams best represent static object connections
- Sequence of messages is more difficult to understand in collaboration diagrams
- Object organization with control flow is best seen through collaboration diagrams
- Complex control is difficult to express in either, but collaboration diagrams can become very complex very quickly
Evaluating the Quality of an Object-Oriented Design
We can analyze encapsulation and delegation to judge whether control is centralized or distributed, hence judging coupling and cohesion. OO design yields more cohesive and loosely coupled systems.
Centralized vs. Distributed Control β Illustrated with a heat regulatory system:
- Poor design (distributed): A
Heat Flow Regulatorcommunicates with three separate objects (Desired Temp,Actual Temp,Occupancy) β high coupling - Better design (encapsulated): The three objects are encapsulated into one
Roomobject β reduced coupling, but control still centralized in the regulator - Best design (delegated): Responsibility is delegated to the
Roomobject with a single messagedoYouNeedHeat()β reduced coupling even further, more cohesive
π‘ Why this matters: Encapsulating related data and behavior into one object and delegating responsibility reduces the number and types of messages, making classes easier to understand and modify.
Reducing coupling by minimizing the number of messages in a class's protocol (public interface):
- Example: Replace
SetMinimumValue(int aValue)andSetMaximimumValue(int aValue)withSetLimits(int minValue, int maxValue) - This reduces protocol complexity
- Caution: Use heuristics judiciously so the functionβs scope does not go beyond providing one single operation
β Key Takeaways
The most critical concepts from this lecture are: (1) Sequence diagrams show time-ordered messages between objects with life lines and activation boxes, while collaboration diagrams show object organization with numbered messages. (2) Message types include synchronous (blocking caller), asynchronous (non-blocking), create (<<create>>), and destroy (<<destroy>>). (3) To evaluate design quality, examine control distribution: centralized control with many messages indicates poor design; encapsulated and delegated control reduces coupling and increases cohesion. (4) Reducing the number of messages in a class's public protocol makes it easier to understand and modify, but avoid over-consolidating unrelated operations. (5) Collaboration diagrams become complex quickly with complex control flow, while sequence diagrams are better for time-based understanding.
π§ Quick Revision Questions
- What is the difference between a synchronous message and an asynchronous message in a sequence diagram?
- What does a life line represent, and how does an activation box relate to it?
- In the heat regulatory system example, why is delegating the
doYouNeedHeat()responsibility to the Room object better than having the Heat Flow Regulator query three separate objects? - When should you avoid modeling object destruction in a sequence diagram?
- What is the main advantage of collaboration diagrams over sequence diagrams, and what is their main disadvantage?
π Lecture 22 β Software and System Architecture
π Overview: This lecture introduces the concept of software architecture, tracing its historical roots to Dijkstra and Parnas, and defines it through multiple authoritative perspectives. It explains why architecture is critical for communication, early design decisions, and reuse, and outlines architectural attributes and the design process. Understanding architecture is essential because it establishes the structural foundation that dictates a system's quality, development, and maintenance.
ποΈ Topics Covered
The lecture begins with an introduction to architectural design and its historical origins with Dijkstra's layered structures and Parnas's information-hiding modules and program families. It then covers multiple formal definitions of software architecture from UML, Bass/Clements/Kazman, Garlan and Perry, IEEE, and Shaw and Garlan. The importance of architecture is explained through three key reasons: mutual communication among stakeholders, early design decisions that constrain implementation and work breakdown, and reusable abstraction for product lines. Finally, the lecture addresses architectural attributes (performance, security, safety, availability, maintainability) and the architectural design process (system structuring, control modeling, modular decomposition).
π Lecture Summary
Introduction
The lecture opens by analogizing software architecture to building architecture, where different stakeholders (architect, contractor, electrician, plumber) have different but related views of the same structure. Architectural design establishes the overall structure of a software system by identifying sub-systems and the framework for their control and communication. The study of software architecture began in 1968 when Edsger Dijkstra introduced the layered structure, where programs are grouped into layers and can only communicate with programs in adjoining layers, yielding conceptual integrity and gains in development and maintenance ease. David Parnas advanced this with contributions on information-hiding modules, software structures, and program familiesβa set of programs considered as a group because it is profitable or useful to do so. Parnas argued that early design decisions should be those most likely to remain constant across members of a program family (such as adopting a particular architecture), while late design decisions should be trivially changeable (such as compile-time or load-time constants). All work in software architecture evolves toward a paradigm based on principles of architecture because structure is important and getting it right carries benefits.
8.2 What is Software Architecture?
There is no single universally accepted definition of software architecture, but at its essence is a focus on reasoning about structural issues of a system. A system is defined by UML 1.3 as a collection of connected units organized to accomplish a specific purpose, and by IEEE Std. 610.12-1990 as a collection of components organized to accomplish a specific function or set of functions.
π Definition β System (UML 1.3): a collection of connected units that are organized to accomplish a specific purpose.
π Definition β System (IEEE Std. 610.12-1990): a collection of components organized to accomplish a specific function or set of functions.
Software Architecture Definitions:
π Definition β Architecture (UML 1.3): the organizational structure of a system, which can be recursively decomposed into parts that interact through interfaces, relationships that connect parts, and constraints for assembling parts. Parts that interact through interfaces include classes, components, and subsystems.
π Definition β Architecture (Bass, Clements, Kazman): the structure or structures of the system, which comprise software components, the externally visible properties of those components, and the relationships among them. "Externally visible" properties refer to assumptions other components can make about a component, such as its provided services, performance characteristics, fault handling, and shared resource usage. The architecture must abstract away some information yet provide enough to be a basis for analysis, decision making, and risk reduction.
π Definition β Architecture (Garlan and Perry): the structure of the components of a program/system, their interrelationships, and principles and guidelines governing their design and evolution over time.
π Definition β Architectural design (IEEE Glossary): The process of defining a collection of hardware and software components and their interfaces to establish the framework for the development of a computer system.
π Definition β Architecture (Shaw and Garlan): the system defined in terms of computational components and interactions among those components. Components include clients, servers, databases, filters, and layers. Interactions include procedure call, shared variable access, client-server protocols, database accessing protocols, asynchronous event multicast, and piped streams.
π‘ Why this matters: Although these definitions differ in wording, they do not conflict; all emphasize structural issues and ways to describe them. Architectural design is an early stage of system design that represents the link between specification and design, provides an abstract view of the solution, identifies critical issues, documents design choices under constraints, and primarily defines non-functional requirements and the environment.
8.3 Why is architecture important?
Barry Boehm states that if a project has not achieved a system architecture, including its rationale, it should not proceed to full-scale system development. There are three fundamental reasons architecture is important:
π 1. Mutual communication: Software architecture represents a common high-level abstraction that most system stakeholders (customer, user, project manager, coder, tester) can use as a basis for mutual understanding, consensus, and communication. It provides a common language in which different concerns can be expressed, negotiated, and resolved at an intellectually manageable level, even for large, complex systems.
π 2. Early design decisions: Software architecture embodies the earliest set of design decisions about a system, and these early bindings carry weight far out of proportion to their individual gravity. An implementation exhibits an architecture if it conforms to the structural design decisionsβdivided into prescribed components, interacting in prescribed fashion, with each component fulfilling its responsibility. Resource allocation decisions also constrain implementation, enabling separation of concerns. The architecture prescribes not only the system structure but also engraves that structure on the work breakdown structureβthe division of labor in a large system, with different groups assigned different portions. The work breakdown structure dictates units of planning, scheduling, budget, inter-team communications channels, configuration control, integration, test plans, and maintenance activities.
π‘ Why this matters: A side effect of establishing the work breakdown structure is to effectively freeze the software architecture, making it almost impossible to modify for managerial and business reasons. This is why extensive analysis must be carried out before freezing the architecture. Fortunately, it is possible to make quality predictions about a system based solely on an evaluation of its architecture.
π 3. Reusable abstraction of a system: Software architecture embodies a relatively small, intellectually graspable model for how the system is structured and how its components work together. This model is transferable across systems and can promote large-scale reuse. In product line development, the architecture defines what is fixed for all members of the family and what is variable. System architects choose an architecture that serves all envisioned members by making design decisions that apply across the family early and decisions that apply only to individual members late. A family-wide design solution may not be optimal for all derived systems, but the quality gained and labor savings from architectural-level reuse may compensate for non-optimality.
8.4 Architectural Attributes
Software architecture must address non-functional as well as functional requirements. The following are architectural design guidelines for addressing these challenges:
- Performance: Enhanced by localising operations to minimise sub-system communicationβuse self-contained modules to minimize inter-module communication.
- Security: Improved by using a layered architecture with critical assets placed in inner layers.
- Safety: Safety-critical components should be isolated.
- Availability: Ensured by building redundancy in the system with redundant components in the architecture.
- Maintainability: Directly related to simplicity; increased by using fine-grain, self-contained components.
8.5 Architectural design process
The design of software architecture is a creative and iterative process involving several activities:
π System structuring: Decomposing the system into interacting sub-systems. The system is decomposed into principal sub-systems, and communications between them are identified. The architectural design is normally expressed as a block diagram presenting an overview of the system structure. A sub-system is a system in its own right whose operation is independent of services provided by other sub-systems. A module is a system component that provides services to other components but would not normally be considered a separate system.
π Control modelling: Establishes a model of the control relationships between the different parts of the system.
π Modular decomposition: The identified sub-systems are decomposed into modules.
β Key Takeaways
The most critical things to remember are: (1) Software architecture is about the structural organization of a systemβits components, their externally visible properties, and their relationshipsβand it defines the framework for sub-system control and communication. (2) Architecture is important for three key reasons: it enables mutual communication among stakeholders, it embodies early design decisions that constrain the entire development and work breakdown structure, and it provides a reusable abstraction for product lines. (3) Non-functional attributes (performance, security, safety, availability, maintainability) must be addressed architecturally through specific design guidelines like localizing operations, layering for security, isolating safety-critical components, building redundancy, and using fine-grain self-contained modules. (4) The architectural design process is iterative and includes system structuring (decomposing into sub-systems), control modeling (establishing control relationships), and modular decomposition. (5) Once the architecture's module structure is agreed upon and used as the work breakdown structure, it becomes nearly impossible to modify for managerial and business reasons, so extensive analysis must precede freezing the architecture.
π§ Quick Revision Questions
- What did Dijkstra contribute to the study of software architecture, and what was his key concept?
- According to Bass, Clements, and Kazman, what are "externally visible properties" of a component in an architectural definition?
- List and explain the three fundamental reasons why software architecture is important.
- For each of the following architectural attributes, give one design guideline: performance, security, safety, availability, and maintainability.
- Describe the three main activities in the architectural design process: system structuring, control modeling, and modular decomposition.