π Lecture 11 β Software Design
π Overview: This lecture introduces the software design phase, where the focus shifts from requirements (what) to implementation (how). It covers strategies for managing complexity, fundamental design approaches (structured vs. object-oriented), and the qualities that define a good, maintainable software design.
ποΈ Topics Covered
The lecture covers the introduction to software design as the phase where system structure is modeled, including data models, components, and interfaces. It explains managing complexity through separation of concerns, modularity, and abstraction. The software design process is described as iterative, involving multiple models at different abstraction levels. Two fundamental design strategies are compared: functional (structured) and object-oriented design. Finally, the qualities of software design are discussed, with a focus on maintainability, cohesion, and loose coupling.
π Lecture Summary
6.1 Introduction
Once requirements are established, the design phase shifts focus from what to how. The objective is to analyze and understand the system in detail to identify and document features and components of at least one feasible solution. The design activity provides a roadmap to progressively transform requirements into the final product by describing the system's structure to be implemented.
This includes modeling data structures and entities, the physical and logical partitioning of the system into components, and the interfaces between different components as well as to the outside world. Sometimes, design of algorithms is also included.
π Definition β Software Design: The process of analyzing and understanding a system in detail so that features and constituent components of at least one feasible solution are identified and documented, providing a roadmap for implementation.
6.2 Managing Complexity of a Software System
A complex system that works is invariably found to have evolved from a simple system that worked. We understand only those systems that have a hierarchical structure and where intra-component linkages are generally stronger than inter-component linkages. To manage complexity, we apply the principles of separation of concern, modularity, and abstraction.
Separation of concern allows us to deal with different individual aspects of a problem in isolation, independent of each other.
Modularity is the classic divide-and-conquer philosophy: a complex system is divided into smaller pieces of lesser complexity called modules. One major advantage is that it allows the designer to apply separation of concern on individual modules.
π‘ Why this matters: These principles lead to designs that are easy to understand and hence easy to maintain.
π Definition β Separation of Concern: A design principle that allows dealing with different individual aspects of a problem by considering these aspects in isolation and independent of each other. π Definition β Modularity: The division of a complex system into smaller pieces (modules) of lesser complexity, following the divide-and-conquer philosophy.
Software Design Process
Software design is not a sequential process; it evolves through a number of iterations. The process usually involves developing several different models, looking at the system from different angles and describing it at various levels of abstraction. These models complement each other, much like the models used during requirement engineering.
Activities at this stage include:
- Design of the software architecture showing division into sub-systems or modules
- Specification of services provided by sub-systems and their interfaces
- Division of each sub-system into smaller components with their own services and interfaces
- Data modeling including identification of data entities, their attributes, relationships, and appropriate data structures
Software Design Strategies
The design process revolves around decomposing the system into smaller units and then systematically integrating them. Two fundamental strategies are used:
Functional or Structured Design: The structure revolves around functions. The entire system is abstracted as a main function that is decomposed into smaller functions. The main function delegates responsibilities to these smaller functions and makes calls to them. The process continues until functions are at a level of granularity where they can be easily implemented. The system state (data) is centralized and shared by all functions.
Object-Oriented Design: The system is decomposed into a set of objects that cooperate and coordinate with each other. The system state is decentralized, and each object is responsible for maintaining its own state. Communication and coordination are achieved through message passing, where one object requests services from another object.
The object-oriented approach has gained popularity over the structured design approach because, in general, it yields a design that is more maintainable than the one produced by the functional approach.
π Definition β Functional Design: A design strategy where the system structure revolves around functions, with a centralized system state shared by all functions. π Definition β Object-Oriented Design: A design strategy where the system is decomposed into objects with decentralized state, communicating through message passing.
Software Design Qualities
A software design can be measured and analyzed using different parameters:
- Efficiency
- Compactness
- Reusability
- Maintainability
A good design from one perspective may not be suitable from another. For example, an efficient and compact design may not be easy to maintain. The project and application requirements determine quality priorities. An embedded system for a nuclear reactor may prioritize efficiency, while a business system would prioritize maintainability.
Maintainable Design
Since maintenance contributes to a major share of overall software cost, the objective in most cases is to produce a system that is easy to maintain. A maintainable design minimizes the cost of system change and is flexible enough to easily modify existing functionality and add new functionality.
To achieve maintainability, the design should be understandable and changes should be local in effect β a change in one part should not affect other parts. This is achieved by applying the principles of modularity, abstraction, and separation of concern. When applied properly, these principles yield a design that is more cohesive and loosely coupled, and thus easy to maintain.
π Definition β Maintainable Design: A design where the cost of system change is minimal and the system is flexible enough to be easily adapted to modify existing functionality and add new functionality. π Definition β Cohesion: A measure of how strongly related the elements within a module are to each other (higher cohesion is better). π Definition β Coupling: A measure of the degree of interdependence between modules (loose coupling is better).
β Key Takeaways
The software design phase shifts focus from what the system should do to how it will be built, providing a roadmap for implementation through iterative modeling. To manage complexity, designers must apply the principles of separation of concern, modularity, and abstraction, which lead to hierarchical structures where intra-component linkages are stronger than inter-component linkages. Two fundamental design strategies exist: functional design with centralized data and object-oriented design with decentralized data and message passing, with the latter generally producing more maintainable designs. Maintainability is typically the primary design goal because it accounts for the largest share of software cost, achieved when designs are understandable and changes have local effects. A maintainable design is characterized by high cohesion within modules and loose coupling between modules, resulting from proper application of the core design principles.
π§ Quick Revision Questions
- What is the fundamental shift in focus that occurs when moving from requirements engineering to the software design phase?
- What three principles are applied to manage the complexity of a software system, and how does each contribute to better design?
- How do functional (structured) design and object-oriented design differ in their approach to system state and inter-component communication?
- Why is maintainability typically the primary quality objective in software design, and what two characteristics make a design maintainable?
- What do the terms "cohesion" and "coupling" mean in the context of software design, and what values of each indicate a good design?
π Lecture 12 β Coupling and Cohesion
π Overview: This lecture explores two critical software design concepts: coupling and cohesion, which measure the independence and internal consistency of modules. Understanding these principles helps engineers create modular, maintainable, and reusable software. The lecture also covers abstraction, encapsulation, and contrasts function-oriented vs. object-oriented design approaches.
ποΈ Topics Covered
The lecture covers definitions and measures of coupling and cohesion, their graphical representation, and detailed examples demonstrating low vs. high coupling using a vector class and low vs. high cohesion using an order class. It then introduces abstraction and encapsulation with a sorting algorithm example, and concludes with a comparison of function-oriented versus object-oriented design.
π Lecture Summary
6.3 Coupling and Cohesion
Coupling is a measure of the independence of a module or component. Loose coupling means different system components have less reliance upon each other, so changes in one component have a limited effect on others. Strong cohesion implies that all parts of a component should have a close logical relationship with each other, meaning all related pieces are found in one place when changes are required.
A component should implement a single concept or a single logical entity. All parts of a component should be related to each other and necessary for implementing that component. If a component includes unrelated parts, it is said to have low cohesion.
Coupling and cohesion are contrasting concepts but indirectly related. Cohesion is an internal property of a module (intra-component linkages), while coupling is its relationship with other modules (inter-component linkages). If modules are more independent, they will be less dependent upon others. Therefore, a highly cohesive system also implies less coupling.
A good example of a system with very high cohesion and very low (almost nil) coupling is the electric subsystem of a house made up of electrical appliances and wires. Each appliance has a clearly definable function completely encapsulated within it, meaning an appliance does not depend upon any other for its function. However, adding a centralized control unit to control appliances according to certain settings creates more coupling.
Modules with high cohesion and low coupling can be treated and analyzed as black boxes, allowing us to analyze them independently by applying the principle of separation of concern.
π Definition β Coupling: A measure of the interdependence of two modules. π Definition β Cohesion: A measure of the independence of a module's internal parts. π Definition β Separation of Concern: The principle of analyzing modules independent of other modules.
Coupling and cohesion can be represented graphically. In a highly coupled system, module boundaries are not well defined, as everything seems connected to everything else through shared data. In a low coupling system, module boundaries are well defined, intra-component linkages are stronger while inter-component linkages are weak.
π Example of Coupling: Modules that interact through message passing have low coupling, while those interacting through variables that maintain state information have high coupling.
Consider a vector class with public data members:
class vector {
public:
float x;
float y;
vector (float x, float y);
float getX();
float getY();
float getMagnitude();
float getAngle();
};
A function to calculate dot product can be written using the public interface (loose coupling):
float myDotProduct1(vector a, vector b) {
float temp1 = a.getX() * b.getX();
float temp2 = a.getY() * b.getY();
return temp1 + temp2;
}
Or directly using public data members (tight coupling):
float myDotProduct2(vector a, vector b) {
float temp1 = a.x * b.x;
float temp2 = a.y * b.y;
return temp1 + temp2;
}
If the class designer changes the implementation to store magnitude and angle instead of x and y:
class vector {
public:
float magnitude;
float angle;
// ... methods remain the same
};
The first version (myDotProduct1) using the public interface requires no change because the system was loosely coupled. The second version (myDotProduct2) must be rewritten because it had more dependency on the internal structure and hence more coupling.
π‘ Why this matters: This example demonstrates how tight coupling creates ripple effects when implementation details change, making maintenance costly and error-prone.
π Example of Cohesion: A class is cohesive if most of the methods defined in the class use most of the data members most of the time. If different subsets of data are manipulated by separate groups of functions, the class is not cohesive and should be broken down.
Consider an order class mixing order and customer information:
class order {
public:
int getOrderID();
date getOrderDate();
float getTotalPrice();
int getCustomerId();
string getCustomerName();
string getCustomerAddress();
int getCustomerPhone();
// ... setters for all
private:
int orderId;
date orderDate;
float totalPrice;
item lineItems[20];
int customerId;
string customerName;
int customerPhone;
int customerFax;
};
This class is not cohesive because it contains information about both the order and the customer, which are distinct entities. It must be broken into two separate, more cohesive classes:
class order {
public:
int getOrderID();
date getOrderDate();
float getTotalPrice();
int getCustomerId();
void setOrderID(int oId);
void setOrderDate(date oDate);
void setTotalPrice(float tPrice);
void setCustomerId(int cId);
void addLineItem(item anItem);
private:
int orderId;
date orderDate;
float totalPrice;
item lineItems[20];
int customerId;
};
class customer {
public:
int getCustomerId();
string getCustomerName();
string getCustomerAddress();
int getCustomerPhone();
int getCustomerFax();
// ... setters
private:
int customerId;
string customerName;
int customerPhone;
int customerFax;
};
6.4 Abstraction and Encapsulation
Abstraction is a technique where we construct a model of an entity based upon its essential characteristics and ignore the inessential details. The principle of abstraction helps handle the inherent complexity of a system by allowing us to look at important external characteristics while hiding inner complexity. Encapsulation is hiding the internal details. Abstraction is a special case of separation of concern, where we separate the concern of users who only need to understand the external interface without bothering about actual implementation.
π Definition β Abstraction: A technique of modeling an entity based on its essential characteristics, ignoring inessential details. π Definition β Encapsulation: Hiding the internal details of a component.
π Example: A selectionSort function can be rewritten by abstracting logical steps into auxiliary functions. The original function:
void selectionSort(int a[], int size) {
int i, j, min, temp;
for(i = 0; i < size β1; i++) {
min = i;
for (j = i; j < size; j++) {
if (a[j] < a[min])
min = j;
}
temp = a[i];
a[i] = a[min];
a[min] = temp;
}
}
By abstracting out swapping and finding the minimum value:
void swap(int &x, int &y) {
int temp;
temp = x;
x = y;
y = temp;
}
int indexOfMinimumValue(int a[], int from, int to) {
int i, min;
min = from;
for (i = from+1; i < to; i++)
if (a[i] < a[min]) min = i;
return min;
}
void selectionSort(int a[], int size) {
int i, min;
for (i = 0; i < size; i++) {
min = indexOfMinimumValue(a, i, size);
swap(a[i], a[min]);
}
}
The resultant function is easier to understand. As a by-product, we created two general-purpose reusable functions. The principle of abstraction thus generates reusable self-contained components.
6.5 Function Oriented versus Object Oriented Design
In the action-oriented (function-oriented) approach, data is decomposed according to functionality requirements; decomposition revolves around function. In the OO approach, decomposition revolves around data (objects). The action-oriented paradigm focuses only on functionality, typically ignoring data until required. The OO paradigm focuses on both functionality and data simultaneously.
The basic difference is centralized control mechanism (action-oriented) versus decentralized control mechanism (OO). Decentralization gives OO the ability to handle essential complexity better.
π Definition β Action-Oriented Design: An approach where decomposition revolves around functions, and data is managed separately. π Definition β Object-Oriented Design: An approach where decomposition revolves around data (objects), and relevant data and functionality are kept together.
In action-oriented design, function knows about the data it uses, but data does not know about the functions using it. This means changing a function is easy (you know which data is affected), but changing a data structure is difficult (hard to find all functions using that data). Object-oriented approach solves this by putting relevant data and functionality together at one place. In case of change, affected components can be identified easily, and the effect is localized. Data is not shared; anyone needing information sends a message through the object's interface. This creates highly cohesive objects by keeping related data and function together and spinning-off non-related information into other classes.
β Key Takeaways
A student must remember that cohesion measures internal consistency within a module while coupling measures interdependence between modules; high cohesion implies low coupling. The core principle is that components should implement a single logical entity with all parts being necessary and related. When changes are required, tightly coupled systems cause ripple effects, as shown in the vector class example where accessing public data members directly caused rewriting when implementation changed. Abstraction and encapsulation are key techniques for managing complexity by hiding internal details and exposing only essential interfaces. Finally, object-oriented design offers advantages over function-oriented design by localizing the impact of changes and creating decentralized control through highly cohesive objects.
π§ Quick Revision Questions
- What is the difference between coupling and cohesion, and how are they related?
- In the vector class example, why did
myDotProduct2need to be rewritten whilemyDotProduct1did not? - What makes a class non-cohesive, and how should it be fixed? Use the order class example.
- How does abstraction lead to reusable components, and what is the difference between abstraction and encapsulation?
- What is the fundamental difference between action-oriented and object-oriented design in terms where data and functions are placed?
π Lecture 13 β Object Oriented Analysis and Design
π Overview: This lecture introduces Object-Oriented (OO) technology and explains why it evolved to bridge the gap between real-life objects and their software counterparts. It covers the fundamental components of OO design, including objects, classes, classification, and the object model, and provides a detailed comparison of inter-object relationshipsβparticularly association versus aggregationβwith conceptual and implementation differences.
ποΈ Topics Covered
The lecture begins with an explanation of why object-oriented design is necessary, contrasting it with function-oriented approaches. It then defines the basic OO components: objects and classes. Classification of objects is discussed with examples. The object model is presented, covering abstraction, encapsulation, and hierarchy. Finally, the three inter-object relationships (inheritance, association, and aggregation) are explored in depth, with a detailed comparison of association and aggregation across multiple dimensions.
π Lecture Summary
Object Oriented Design - Why?
Software models real-life entities and processes. Traditional approaches treated software as separate information and procedures without explicit relationships, hiding the mapping between software components and real-world objects. Object-oriented technology evolved to bridge this gap by encapsulating data and processes related to a real-life object into a single software entity. It also allows objects to inherit properties from ancestors, similar to real-life inheritance.
A complex system that works evolved from a simple system that worked. Hierarchical structure with stronger intra-component linkages than inter-component linkages leads to loose coupling, high cohesion, and better maintainability. An OO system consists of objects that are hierarchical, highly cohesive, and loosely coupled.
Key advantages of OO technology include:
- Clarity and understandabilityβcloser to human cognition
- Reusabilityβfrom low interdependence and inheritance
- Reduced maintenance effortβfrom inheritance, encapsulation, low coupling, and high cohesion
π Definition β Function-oriented (action-oriented) approach: Data is decomposed according to functionality requirements; decomposition revolves around function. π Definition β Object-oriented approach: Decomposition revolves around data; focuses on both functionality and data simultaneously. It uses decentralized control as opposed to centralized control in action-oriented approach.
π Example: In a function-oriented approach, functions know about the data they use, but data does not know about functions using it. Changing a function is easy because affected data components are known. However, changing a data structure is difficult because all functions using that data must be found and modified. In OO, since data and function are encapsulated in one class, the effect of change is localized, making maintenance easier.
Object Oriented Design Components - What?
The Object and the Class
The basic unit of OO design is an object. An object is a tangible entity that exhibits well-defined behavior. It represents an individual, identifiable item, unit, or entityβreal or abstractβwith a defined role in the problem domain. An object has state, behavior, and identity.
- State: All properties of the object and their current values. Properties are usually static. State is encapsulated within the object.
- Behavior: How an object acts and reacts in terms of state changes and message passing. A message is an action one object performs upon another to elicit a reaction. Operations clients may perform are called methods.
- Identity: The unique existence of an object.
A class defines the structure and behavior of similar objects. A class represents an abstractionβthe essence or template of an object. It specifies an interface (outside view, public part) and defines an implementation (inside view, private part). The interface contains declarations of all operations applicable to instances of the class; the implementation contains the actual code for those operations.
Classification
Classification is the most important and critical stage in OOA and OODβappropriate grouping of objects into classes. Proper classification requires looking at the problem from different angles. The same object can be classified into different categories depending on perspective.
π Example: A horse can be classified based on:
- Data-driven: head, tail, body, leg
- Behavior-driven: walk, run, eat
- Responsibility-driven: carry things, communicate, maintain its living system
The Object Model
The elements of OO design collectively form the Object Model, which encompasses the principles of abstraction, encapsulation, and hierarchy (inheritance).
- Abstraction: A powerful technique for dealing with complexity by ignoring essential details and dealing with a generalized, idealized model. It focuses on the outside view, separating external behavior from implementation. Deciding the right set of abstractions is the central problem in OO design.
- Encapsulation: Hides implementation details of an object. Abstraction and encapsulation are complementaryβabstraction provides the outside view, encapsulation prevents clients from seeing the inside view. Intelligent encapsulation localizes design decisions likely to change. The essential benefit: changing an object's representation without disturbing clients.
π‘ Why this matters: Abstraction and encapsulation together allow developers to manage complexity by focusing on what an object does (interface) rather than how it does it (implementation), enabling modularity and easier maintenance.
Relationship Among Objects
The object model presents a static view of the system and illustrates how objects collaborate. Three inter-object relationships are specified:
- Inheritance: Defines a "kind of" hierarchy (generalization/specialization). A subclass shares structure and behavior defined in a superclass. A subclass augments or redefines existing structure and behavior. Identifying hierarchy requires discovering patterns among many objects.
- Association: When object A "uses" object B, A may send messages to B. This defines visibility among objects.
- Aggregation: Defines "part-of" structure. When object A is part of the state of object B, A is contained by B. Aggregation reduces the number of visible objects at the enclosing level but may lead to tighter coupling.
Aggregation and Association - Conceptual and Implementation Issues and Differences
Association and Aggregation - Some basic differences
Objects collaborate in many ways to achieve goals. The three relationship types are:
- Inheritance: "kind of" relationship
- Aggregation: "part of" relationship
- Association: some semantic connection among otherwise unrelated classes
Aggregation is the "part-whole" or "a-part-of" relationship where components are encapsulated within an assembly. The whole is meaningless without its parts, and parts cannot exist without the container. Properties of the assembly may propagate to components. Aggregation implies tighter coupling than association.
π Definition β Aggregation vs. Association (basic rule): If two objects are tightly coupled and cannot exist independently, it is aggregation. If they are usually independent, it is association.
Object Creation and Life Time
When an object (the whole) is instantiated, all its parts must also be instantiated at the same time before useful work can be done. All parts die with the whole. In association, the lifetime of two associated objects is independentβthe only limitation is that an object must be alive before a message can be sent to it.
Coupling and Linkages
Aggregation implies much tighter coupling than association. The links between whole and part are permanent in aggregation. In association, links may be maintained only for the period an object requires services of its associated object and may be disconnected afterward.
Ownership and visibility
In aggregation, since the whole contains the part, the part is encapsulated or hidden within the whole and is not accessible from outside. Only the whole can send messages to its parts. The whole owns its parts, and the part becomes a private property of the wholeβother objects do not need to know about its existence. In association, the associated object may be shared among many objectsβmany objects may hold a reference to the same object simultaneously.
π Definition β Ownership: In aggregation, the whole owns its parts (private). In association, objects are shared (public reference).
Database persistence
When an object is persisted (stored) in a database, all its components (all parts of the whole) must also be persisted in their entirety along with the whole for future reference. For association, only a reference to the associated object may be stored in the database. A normalized database enforces this restriction.
β Key Takeaways
Object-oriented design emerged to bridge the gap between real-world entities and software by encapsulating data and behavior into objects, promoting clarity, reusability, and maintainability. The fundamental building blocks are objects (with state, behavior, and identity) and classes (templates defining interface and implementation). The object model rests on three principles: abstraction (focusing on outside view), encapsulation (hiding implementation), and hierarchy/inheritance (defining generalization-specialization relationships). Understanding the difference between association (loose, independent, shareable, temporary links) and aggregation (tight, part-whole, ownership, permanent links with dependent lifetimes) is critical for proper OO design. The key distinguishing factor across all dimensions is couplingβaggregation implies tighter coupling than association.
π§ Quick Revision Questions
- What are the three main advantages of object-oriented technology over other approaches?
- How does the concept of "decentralized control" differ between function-oriented and object-oriented approaches?
- Define and distinguish between an object and a class in OO design.
- What are the three principles encompassed by the object model, and explain each briefly.
- List four ways to differentiate between association and aggregation relationships.
π Lecture 14 β Object Oriented Design
π Overview: This lecture explores the process of transforming an analysis model into a design model using Object-Oriented Design (OOD). It introduces the four-layer OOD pyramid and details Object-Oriented Analysis (OOA) techniques, with a focus on Abbotβs Textual Analysis for identifying classes and their components from problem statements. Understanding this translation is crucial for creating a structured blueprint for software construction.
ποΈ Topics Covered
The lecture covers the four layers of the Object-Oriented Design pyramid: subsystem, class and object, message, and responsibility layers. It then explains the translation from the analysis model to the design model. The focus shifts to Object-Oriented Analysis, including tasks for static and dynamic modeling. Finally, the lecture details Abbotβs Textual Analysis technique, using parts of speech to identify model components and an example of a cash register to practice identifying and eliminating classes.
π Lecture Summary
Object Oriented Design
Object-Oriented Design (OOD) transforms the analysis model into a design model that serves as a blueprint for software construction. OOD results in a design that achieves a number of different levels of modularity. The four layers of the OO design pyramid are:
- The subsystem layer. Contains a representation of each of the subsystems that enable the software to achieve its customers defined requirements and to implement the technical infrastructure that supports customer requirements.
- The class and object layer. Contains the class hierarchies that enable the system to be created using generalization and increasingly more targeted specializations. The layer also contains design representations for each object.
- The message layer. Contains the details that enable each object to communicate with its collaborators. This layer establishes the external and internal interfaces for the system.
- The responsibility layer. Contains the data structures and algorithmic design for all attributes and operations for each object.
π‘ Why this matters: Understanding these four layers ensures that the design covers all critical aspects of a software system, from high-level subsystems to low-level data structures and communication protocols.
Translating the analysis model into a design model during object design
The lecture presents a diagram showing the translation from an Analysis Model (containing classes, attributes, methods, relationships, behavior) to a Design Model (containing objects, data structures, algorithms, messaging, control). This translation is the core activity of OOD.
π Definition β OOD: The process of transforming the analysis model into a design model that serves as a blueprint for software construction.
Object Oriented Analysis
The intent of Object-Oriented Analysis (OOA) is to define all classes, their relationships, and their behavior. A number of tasks must occur:
- Static Model a) Identify classes (i.e. attributes and methods are defined) b) Specify class hierarchy c) Identify object-to-object relationships d) Model the object behavior
- Dynamic Model a) Scenario Diagrams
π Definition β OOA: The process of defining all classes, their relationships, and their behavior.
Object-Oriented Analysis using Abbotβs Textual Analysis
The first object-orientation technique studied is one of the oldest techniques to identify objects and their relationships: Textual Analysis. It was initially developed by Abbot and then extended by Graham and others. In this technique, different parts of speech are identified within the text of the specification, and these parts are modeled using different components.
| Part of speech | Model component | Example |
|---|---|---|
| proper noun | instance | Mehdi Hassan |
| improper noun | class/type/role | student, teacher |
| doing verb | operation | buy |
| being verb | classification | is a horse, is a book |
| having verb | composition | fan has wings |
| adjective | attribute value or class | this ball is green |
| adjective phrase | association | the customer with children, the customer who bought the kite |
Once all the model components have been identified, we will eliminate the redundant or irrelevant components by again analyzing the text and the context of the problem.
Letβs now try to understand this with the help of an example:
Problem Statement: A simple cash register has a display, an electronic wire with a plug, and a numeric keypad, which has keys for subtotal, tax, and total. This cash storage device has a total key, which triggers the release on the drawer. The numeric buttons simply place a number on the display screen, the subtotal displays the current total, the tax key computes the tax, and the total key adds the subtotal to the tax.
Our task now is to:
- Identify all the classes in this problem statement.
- Eliminate the unnecessary classes.
We are now going to use nouns to find classes.
Nouns (initial) Register, Display, Wire, Plug, Keypad, Keys, Devices, Release, Drawer, Buttons, Screen, Number, Total, Tax
Nouns (General Knowledge) 0-9 keys, Money, Subtotal Key, Tax Key, Total Key
Eliminating Irrelevant/Redundant Nouns We now analyze the identified nouns and try to establish whether they would be stand-alone classes in our domain or not. The outcome of this analysis is shown below.
- Register
- Display
- Wire β Irrelevant
- Plug β Irrelevant
- Keypad
- Keys
- Devices β Vague
- Release β Irrelevant
- Drawer
- Buttons β Redundant
- Screen β Redundant
- Number β Attribute
- Total β Attribute
- Tax β Attribute
- 0-9 Key
- Value β Attribute
- Money
- Subtotal Key
- Tax Key
- Total Key
We will continue with the technique to identify all the constituent components of the model and derive our object-oriented design.
π Definition β Textual Analysis: A technique to identify objects and their relationships by mapping parts of speech in a specification to model components. π Example: In the cash register problem, the noun "Wire" was identified as irrelevant, "Buttons" as redundant, and "Number" as an attribute, not a class.
β Key Takeaways
Object-Oriented Design transforms an analysis model into a design model structured around four layers: subsystem, class and object, message, and responsibility. Object-Oriented Analysis focuses on defining all classes, their relationships, and their behavior through static and dynamic modeling. Abbotβs Textual Analysis is a practical technique for initially identifying model components by mapping parts of speech (nouns, verbs, adjectives) to objects, operations, and attributes. A critical step after identification is to eliminate irrelevant, redundant, or vague nouns and to correctly classify others as attributes rather than classes. The cash register example demonstrates how to apply Textual Analysis to a real problem statement to derive a clean set of classes for design.
π§ Quick Revision Questions
- What are the four layers of the Object-Oriented Design pyramid?
- What is the primary intent of Object-Oriented Analysis (OOA)?
- In Abbotβs Textual Analysis, what model component does an "improper noun" (e.g., "student") map to?
- According to the lecture, why was the noun "Buttons" eliminated from the cash register example?
- What is the purpose of the "Eliminating Irrelevant/Redundant Nouns" step in Textual Analysis?
π Lecture 15 β The Notation
π Overview: This lecture introduces the various notations used for documenting object-oriented design, with a focus on the Unified Modeling Language (UML). It explains why notation is important in software engineering and presents UML as the standard choice for modern design documentation.
ποΈ Topics Covered
The lecture covers the three most popular notations for object-oriented design documentation: Rumbaugh, Booch, and Coad notation, with detailed emphasis on UML (Unified Modeling Language). The key features of UML notation are presented through a diagram, highlighting its comprehensiveness and detail for design documentation.
π Lecture Summary
The Notation
Many different notations are used for documenting object-oriented design. The most popular of these include Rumbaugh, Booch, and Coad notation, and UML (Unified Modeling Language). UML will be used to document the design in this course.
π Definition β UML (Unified Modeling Language): A comprehensive and detailed notation standard used for documenting object-oriented software designs.
π‘ Why this matters: Choosing a standard notation like UML ensures that design documents are universally understood by software engineers, reducing miscommunication and enabling better collaboration across teams.
π Example: The lecture refers to a diagram (not provided in text) that presents the key features of UML notation, showing its comprehensive nature for documenting object-oriented designs.
β Key Takeaways
UML is the most popular and comprehensive notation for documenting object-oriented designs, and it will be the standard used throughout this course. While Rumbaugh, Booch, and Coad notations are also widely recognized, UML serves as the unified standard that incorporates elements from these earlier notations. Understanding UML notation is essential for effectively communicating software design decisions. The notation's key features are extensive and detailed, making it suitable for complex system documentation. Students must become familiar with UML's fundamental components to succeed in object-oriented design documentation.
π§ Quick Revision Questions
- What are the four most popular notations mentioned for documenting object-oriented design?
- Which notation will be used in this course for documenting design?
- What does UML stand for?
- Why is notation important in object-oriented design documentation?
- How does UML compare in comprehensiveness to other notations like Rumbaugh, Booch, and Coad?
π Lecture 16 β Derivation of the Object Model β The Coad Methodology
π Overview: This lecture explains Peter Coad's systematic methodology for deriving object models in software engineering. It divides the process into five key activities, each with specific steps, enabling analysts to identify and categorize objects effectively. Understanding this methodology is crucial for building accurate and maintainable object-oriented system models.
ποΈ Topics Covered
The lecture covers the Coad Methodology for deriving an object model, focusing on five activities for selecting objects: selecting actors, participants, places, transactions, container objects, and tangible things. It also provides important considerations for simplifying the object model, such as ensuring each object has a clear responsibility, avoiding controller objects, and using meaningful domain-specific names.
π Lecture Summary
Select Objects β who am I?
This activity divides objects into different categories to make it easier to find them and establish their attributes, services, and collaborations. It consists of 6 steps.
Select Actors Actors are people and organizations that take part in the system under consideration. Examples include person, organization (agency, company, corporation, foundation). It is important to note that we are talking about actors and not their "roles". For example, a customer is a role that a person plays, so if we have a customer in our problem domain, we will also add a person as an actor in the model.
π Definition β Actor: A person or organization that takes part in the system under consideration. π Example: If a system has a "customer," we must also model "person" as an actor, because customer is a role that person plays.
Select Participants A participant is a role that each actor plays in the system under consideration. Examples include agent, applicant, buyer, cashier, clerk, customer, dealer, distributor, donor, employee, investor, member, officer, owner, policy holder, recipient, student, supervisor, supplier, teacher, worker. The same person may play different roles at different times in the system. If we model this behavior using Generalization-Specialization instead of Actor-Participant, we may end up with multiple inheritance.
π Definition β Participant: A role that an actor plays in the system under consideration. π‘ Why this matters: Keeping actors and participants separate avoids complex multiple inheritance issues when a single person can play multiple roles.
Select Places Places are where things come to rest or places that contain other objects. Examples include airport, assembly-line, bank, city, clinic, country, depot, garage, hanger, hospital, plant, region, sales outlet, service center, shelf, station, store, warehouse, zone.
π Definition β Place: An object that represents a location where things come to rest or that contains other objects.
Select Transactions Transactions are the "events" that must be remembered through time. These are entries that must be maintained in a historical record or log which may be used to answer questions or perform assessments. Transactions usually come from a window (GUI), an object that monitors for a significant event and logs that information, or another system that interacts with the system and logs some information. Examples include agreement, assignment, authorization, contract, delivery, deposit, incident, inquiry, order, payment, problem report, purchase, refund, registration, rental, reservation, sale, shift, shipment, subscription, withdrawal. Nearly all transactions consist of a number of transaction line items.
π Definition β Transaction: An event that must be remembered through time, maintained in a historical record or log.
Select Container Objects Containers are objects that hold other objects. The difference between a container and a place is that a place is a place in the literal sense, while a container is any object that can hold other objects (e.g., bin, box, cabinet, folder, locker, safe, shelf). Therefore, a place is also a container, but every container need not be a place.
π Definition β Container: An object that holds other objects (broader category than "place"). π Example: A "shelf" is both a container and a place; a "folder" is a container but not a place.
Select Tangible Things Take a "walk" through the system and select "tangible" things around you used in the problem domain. These may be characterized as all the remaining (not yet selected) "nouns" that make up the problem domain. Examples include account, book, calendar, cash box, cash drawer, item, plan, procedure, product, schedule, skill, tool, etc.
Considerations for Selecting Objects
While selecting objects, the following considerations should be kept in mind for a simpler (and better) object model:
- Every object that you put in your object model should have some responsibility or role to play in the problem domain. You need to know each object, its attributes, and services. If there is no way to know about the object, remove it from the object model.
- Avoid having controller objects because controllers usually end up with functionality that's better done by other objects themselves, making the message passing more complicated, and resulting in higher coupling. Use delegation instead. The difference is that a controller wants to do everything by himself (doesn't trust anyone), while a good manager delegates responsibility (and takes credit).
- In large systems, several objects are likely to have similar or even identical responsibilities. Look for such objects and seek a common name to simplify the object model.
- Use meaningful class names, names that describe objects in that class. Try to use names from the domain vocabulary to avoid confusion.
π Definition β Delegation: Assigning responsibility to other objects to perform tasks, rather than a controller doing everything itself. π‘ Why this matters: Delegation reduces coupling and simplifies message passing, whereas controllers create complex, tightly coupled systems.
β Key Takeaways
The Coad Methodology provides a structured, step-by-step approach to identifying objects in an object model by categorizing them into actors, participants, places, transactions, containers, and tangible things. A key distinction is between actors (people/organizations) and participants (roles they play), which helps avoid multiple inheritance problems. Every object in the model must have a clear responsibility; objects without one should be removed. Avoid controller objects and instead use delegation to reduce coupling and simplify system design. Always use meaningful, domain-specific names for classes to ensure clarity and maintainability.
π§ Quick Revision Questions
- What are the five main activities in Peter Coad's methodology for deriving an object model?
- What is the difference between an "actor" and a "participant"? Why is this distinction important?
- How do "places" and "containers" differ according to the Coad methodology?
- Why should controller objects be avoided in object models, and what should be used instead?
- What rule should you follow if you cannot determine an object's responsibility, attributes, or services?