UNIT 1: Introduction to Object-Oriented Analysis and Design
1. Fundamentals of Modeling
What is a Model?
A model is an abstract representation of a system or concept, built to understand, visualize, or communicate aspects of that system before building it. It simplifies reality by focusing on essential features while hiding unnecessary details.
Purposes of Modeling (Frequently Examined)
| Purpose | Description |
|---|---|
| Visualization | To see the system as it is or as we want it to be. |
| Specification | To define the system's structure and behavior precisely. |
| Communication | To provide a common language for stakeholders (users, designers, developers). |
| Complexity Management | To break down a complex system into manageable parts. |
| Risk Reduction | To identify flaws early, before implementation costs rise. |
| Documentation | To serve as a reference for future maintenance and extension. |
[!TIP] Exam Focus: Always list at least 4–5 purposes. "Communication" and "Complexity Management" are most commonly cited.
Why Modeling is Required in Analysis & Design?
-
Analysis Phase: Models help understand the problem domain, capture requirements, and establish a shared vision.
-
Design Phase: Models guide the technical blueprint, ensuring the solution is structured, reusable, and maintainable.
-
Avoids Implementation Rush: Direct coding without models leads to structural flaws, missed requirements, and high change costs.
Object-Oriented Approach: Definition & Four Key Aspects
The object-oriented (OO) approach views a system as a collection of interacting objects, each with its own state and behavior.
| Aspect | Definition | Key Idea |
|---|---|---|
| Abstraction | Focusing on essential characteristics of an object while ignoring irrelevant details. | Define a clear contract (what an object does) separate from implementation. |
| Encapsulation | Bundling data (attributes) and methods (operations) that operate on that data within a single unit (class), and restricting direct access. | Information hiding; protect internal state via public interfaces. |
| Inheritance | Mechanism where a new class (subclass) derives properties and behavior from an existing class (superclass). | Promotes code reuse and establishes hierarchical classifications. |
| Polymorphism | Ability of different classes to respond to the same message (method call) in different ways. | "One interface, multiple implementations"; e.g., method overriding/overloading. |
Role of UML in Preparing Models
UML (Unified Modeling Language) is a standardized graphical language for visualizing, specifying, constructing, and documenting OO software artifacts. It provides:
-
A common notation for all stakeholders.
-
A suite of diagram types for different perspectives (structure, behavior, architecture).
-
Tool support for model creation, validation, and code generation.
2. UML Overview
Introduction to UML
-
Purpose: To standardize modeling notations and practices for OO systems.
-
History: Merged notations from Booch, OMT, and OOSE in the 1990s; now maintained by the Object Management Group (OMG).
Classification of UML Diagrams
UML 2.x diagrams are broadly classified into:
| Category | Diagrams | Purpose |
|---|---|---|
| Structural | Class, Object, Composite Structure, Package, Component, Deployment | Show static architecture (what exists). |
| Behavioral | Use Case, Activity, State Machine | Show dynamic behavior (how things change/flow). |
| Interaction (sub-type of Behavioral) | Sequence, Communication (Collaboration), Timing, Interaction Overview | Show object interactions over time. |
[!NOTE] Component and Deployment diagrams are also considered architectural diagrams.
Purpose of Each Diagram Type (Frequently Examined)
| Diagram | Primary Purpose |
|---|---|
| Use Case | Capture functional requirements from user's perspective. |
| Class | Define system's static structure (classes, attributes, operations, relationships). |
| Object | Show a snapshot of system at a moment (instances and links). |
| Sequence | Model time-ordered interactions between objects via messages. |
| Communication (Collaboration) | Model structural organization of objects and their interactions. |
| Activity | Model workflow, business process, or algorithmic logic. |
| State Machine | Model state-dependent behavior of a single object. |
| Component | Show physical, replaceable parts (software components) and their interfaces. |
| Deployment | Show physical arrangement of hardware nodes and software artifacts. |
UML Notations (Frequently Examined)
Common symbols and conventions:
| Notation | Meaning | Example |
|---|---|---|
| Class Box | Compartments: Name, Attributes, Operations | + name: String (public), - age: int (private) |
| Association | Solid line between classes; may have multiplicity and navigability | 1..* (one or more), arrow for navigability |
| Inheritance | Solid line with hollow triangular arrowhead (pointing to superclass) | Subclass → Superclass |
| Dependency | Dashed line with open arrowhead (using direction) | Class A → Class B (A uses B) |
| Aggregation | Hollow diamond on whole side (weak "has-a") | Car ◇ Wheel |
| Composition | Filled diamond on whole side (strong ownership, lifecycle dependency) | House ◆ Room |
| Use Case Ellipse | Oval representing a function; inside system boundary box | |
| Actor Stick Figure | External entity interacting with system | |
| Lifeline | Dashed vertical line in sequence diagram (represents object existence) | |
| Activation Bar | Thin rectangle on lifeline (period of activity) | |
| Message Arrow | Solid line with arrow; synchronous (solid arrowhead), asynchronous (stick arrowhead) | |
| Self-Message | Message arrow looping back to same lifeline |
[!TIP] Multiplicity Cheat Sheet:
0..1(optional),1(exactly one),*(many),1..*(at least one),0..*(zero or more).
3. Use Case Modeling (Frequently Examined)
Use Case Diagram Components
-
Actor: Role played by a user or external system (stick figure). Not necessarily a person.
-
Use Case: Oval representing a discrete unit of functionality that delivers value to an actor.
-
System Boundary: Box enclosing all use cases; defines system scope.
-
Relationships:
-
Association: Solid line connecting actor to use case (actor participates).
-
Include: Dashed arrow with
<<include>>; mandatory sub-function. -
Extend: Dashed arrow with
<<extend>>; optional/conditional extension. -
Generalization: Solid line with hollow arrow; inheritance between actors or use cases.
-
Identifying Actors & Use Cases
-
Actors: Ask "Who uses the system?" or "What external systems interact?" (e.g., Customer, Admin, Payment Gateway).
-
Use Cases: Ask "What tasks does each actor perform?" (e.g.,
Place Order,Make Payment,Generate Report).
Example: Online Shopping System
Update Inventory).
Key Use Cases: Browse Catalog, Add to Cart, Checkout, Process Payment, Track Order.
Relationships: Checkout <<include>> Process Payment; Apply Coupon <<extend>> Checkout.
4. Domain Modeling (Frequently Examined)
Domain Model Concepts
-
Entity Class: Represents a fundamental, long-lived concept in the domain (e.g.,
Customer,Order). Has a unique identity (ID). -
Value Class: Represents a descriptive property or measure (e.g.,
Money,Address). Defined by its attributes, not identity. Often modeled as attributes or separate classes if complex.
Attributes: Suitable Attribute Types
Focus on data type attributes:
| Type | Description | Example |
|---|---|---|
| Primitive | Basic language types (int, string, boolean, date). | orderId: String, quantity: int |
| Complex | Custom or domain-specific types (Money, Address, Email). | total: Money, shipAddress: Address |
| Enumerated | Fixed set of named values. | status: {PENDING, SHIPPED, DELIVERED} |
[!TIP] Use complex types when the property has its own attributes/behavior (e.g.,
Moneyhasamountandcurrency).
Associations (Frequently Examined)
An association represents a structural relationship between classes.
-
Identifying: Look for verbs in requirements ("orders have items", "customer places order").
-
Multiplicity: Specify how many instances participate (1, 0..1, 1..*, *).
-
Navigability: Arrow indicates direction of traversal (optional; often bidirectional).
-
Association Class: If the association itself has attributes (e.g.,
OrderItemwithquantityandprice), model it as a class attached to the association.
Example: Customer — places — Order
Multiplicity: Customer 1 —— 0..* Order (one customer places zero or more orders).
Generalizations (Frequently Examined)
Super-sub class (inheritance) relationship.
-
Identify: "Is-a" relationship. E.g.,
Paymentis a superclass;CreditCardPayment,PayPalPaymentare subclasses. -
UML Notation: Solid line with hollow arrow pointing to superclass.
-
When to use: When subclasses share common attributes/operations but have specialized variations.
Domain Model vs. Design Model
| Domain Model | Design Model |
|---|---|
| Analysis-level; focuses on business concepts and requirements. | Design-level; focuses on technical solution and implementation details. |
| Minimal behavior (mostly attributes). | Rich in operations (methods), visibility (+/-/#), and design patterns. |
| No controllers, interfaces, or technology-specific classes. | Includes controllers, facades, data access objects, etc. |
| Entities reflect real-world notions. | Entities reflect software responsibilities (e.g., OrderService). |
Common Errors When Rushing to Implementation
-
Turning every noun into a class → bloated, irrelevant classes.
-
Missing associations → isolated classes, no connectivity.
-
Overusing inheritance → deep hierarchies, fragile base class problem.
-
Ignoring multiplicities → ambiguous relationships.
-
Adding design details prematurely (e.g., databases, UI controls) → domain model becomes implementation-specific.
Deciding Which Classes/Associations/Generalizations to Eliminate
-
Eliminate classes that:
-
Represent transient values (model as attributes instead).
-
Have no meaningful responsibilities or attributes.
-
Are purely implementation artifacts (defer to design).
-
-
Simplify associations by:
-
Removing unnecessary navigability arrows.
-
Reducing multiplicity to simplest valid form.
-
Merging weak associations into attributes.
-
-
Prune generalizations if:
-
Subclasses differ only by data (use attributes instead).
-
Inheritance violates Liskov Substitution Principle.
-
Only one or two subclasses exist (consider flattening).
-
5. Transition from Analysis to Design
From Domain Model to Design Model
-
Refine Classes: Add operations (methods) based on required behavior. Define visibility (
+public,-private,#protected). -
Add Design Elements:
-
Controllers/Facades: Handle use case logic (e.g.,
OrderController). -
Interfaces: Define contracts for services (e.g.,
PaymentProcessor). -
Data Access Objects (DAOs): Isolate persistence logic.
-
-
Eliminate Analysis-Only Elements: Remove vague business terms not needed in software (e.g.,
Customermight stay, butBusinessRulemight become a method). -
Optimize Associations: Convert bidirectional to unidirectional if navigation is one-way; introduce indirection (e.g.,
Order→CustomerDAOinstead of direct link). -
Apply Design Patterns: Where appropriate (e.g., Strategy for payment algorithms, Observer for notifications).
[!TIP] The design model should be implementation-ready but still language-agnostic (UML level).
6. Interaction Diagrams (Highly Frequently Examined)
Sequence Diagrams (Highly Frequently Examined)
Purpose: Model the time-ordered sequence of messages between objects for a specific scenario (use case or operation).
Elements:
-
Lifeline: Dashed vertical line; represents an individual participant (object/class instance) over time.
-
Activation Bar: Thin rectangle on lifeline; shows period an object is performing an action.
-
Message: Horizontal arrow between lifelines; synchronous (solid arrowhead, caller waits) or asynchronous (stick arrowhead, caller continues).
-
Self-Message: Message arrow looping back to same lifeline (recursion or internal processing).
-
Destroy: X at end of lifeline; object is deleted.
-
Frame: Rectangle around diagram; may have name and fragment type (
alt,loop,opt).
Creation Steps:
-
Identify scenario (e.g., "withdraw cash" in ATM).
-
List participating objects (actors + system objects).
-
Arrange lifelines vertically (time flows downward).
-
Add messages in chronological order from top to bottom.
-
Use frames for conditional/iterative logic.
Example: Library Management (Issue/Renew Book)
Member, LibrarySystem, Book, LoanRecord.
Scenario Issue: Member → LibrarySystem: findBook() → Book: isAvailable() → LibrarySystem: createLoan() → LoanRecord: save().
Scenario Renew: Member → LibrarySystem: renewLoan(loanId) → LoanRecord: extendDueDate().
Collaboration Diagrams (Communication Diagrams)
Purpose: Emphasize structural organization of objects and their links; messages are numbered for sequence.
Elements:
-
Links: Solid lines connecting objects (like associations).
-
Numbered Messages:
1.,2., etc., near link; sequence indicated by numbering (can have1a,1bfor concurrent). -
Object Boxes: Same as sequence diagram lifeline headers (object:Class).
Key Difference from Sequence: Collaboration diagrams focus on object relationships; sequence diagrams focus on time ordering. Sequence is better for complex timing; collaboration for simpler scenarios with many objects.
Comparison: Sequence vs. Collaboration Diagrams (Frequently Examined)
| Feature | Sequence Diagram | Collaboration (Communication) Diagram |
|---|---|---|
| Primary Focus | Time sequence of messages | Structural links between objects |
| Layout | Lifelines vertical; time flows down | Objects placed arbitrarily; links show connections |
| Message Indication | Vertical position implies order | Explicit numbering (1, 2, 3...) |
| Readability | Clear for temporal logic | Clear for object connectivity |
| Complexity Handling | Better for many messages over time | Becomes cluttered with many objects/messages |
| UML 2.x | Still supported | Renamed to Communication Diagram |
[!TIP] When to use which? Use sequence for detailed algorithmic flow or real-time constraints. Use communication for overview of object collaborations in a single scenario.
When to Use Interaction Diagrams vs. Activity Diagrams
-
Interaction Diagrams (Sequence/Communication): Model object-to-object interactions for a specific scenario. Who talks to whom, and in what order?
-
Activity Diagrams: Model workflow or business process across multiple actors/systems. What are the steps, decisions, and parallel flows? Use when you need to show branching, merging, or parallel activities not tied to specific objects.
7. Activity Diagrams
Purpose
Model:
-
Business processes or workflows.
-
Algorithm logic (especially complex control flow).
-
Parallel/concurrent activities.
Notation
-
Action: Rounded rectangle; atomic step.
-
Decision Node: Diamond; branches based on guard condition
[condition]. -
Merge Node: Diamond; combines alternative flows.
-
Fork Node: Thick bar; splits into parallel flows.
-
Join Node: Thick bar; synchronizes parallel flows.
-
Swimlane: Vertical/horizontal partition; groups actions by responsible actor or class.
-
Start/End: Solid circle / bullseye.
When NOT to Use Activity Diagrams (Frequently Examined)
| Situation | Preferable Alternative | Reason |
|---|---|---|
| Modeling functional requirements from user's view | Use Case Diagram | Use cases capture high-level user goals; activity diagrams get into procedural detail prematurely. |
| Modeling object interactions for a scenario | Sequence/Communication Diagram | Interaction diagrams show which objects send/receive messages; activity diagrams don't show object roles. |
| Showing a snapshot of object states at a point in time | Object Diagram | Object diagram shows instances and links at a moment; activity diagram shows flow of activities. |
| Simple linear flow with no decisions/parallelism | Textual description or pseudocode | Overkill; simple narrative suffices. |
Practical Situations for Other Diagrams
-
Use Case Diagram: During requirements gathering to outline system scope and user roles.
-
Object Diagram: To illustrate a complex data structure or debug a specific runtime state.
-
Interaction Diagram: To detail how a use case is realized through object collaborations (design phase).
8. Structural Diagrams (Advanced)
Class Diagrams (Design-Level)
Recap from domain model, but at design level:
-
Add operations (methods) with parameters.
-
Specify visibility (
+public,-private,#protected). -
Include design patterns (e.g.,
<<interface>>stereotype). -
May show inner classes, templates (generics).
Object Diagrams (Frequently Examined)
-
Purpose: Show a snapshot of instances (objects) and their links at a specific moment. Like a "running" class diagram.
-
Notation: Object boxes:
objectName:ClassName(e.g.,c1:Customer). Links are instances of associations. -
When to Use:
-
To illustrate complex data structures (e.g., linked list, tree).
-
To provide a concrete example of a class diagram.
-
For debugging or explaining a particular runtime scenario.
-
Not for overall system design; only for representative snapshots.
-
Component Diagrams (Frequently Examined)
-
Purpose: Show physical, replaceable parts (components) of a system and their interfaces/dependencies.
-
Elements:
-
Component: Rectangle with
<<component>>stereotype and small "plug" icon. -
Interface: Circle or rectangle with
<<interface>>; lollipop (provided) or socket (required) notation. -
Dependency: Dashed arrow from client to supplier.
-
-
Component Models (Frequently Examined):
-
CORBA (Common Object Request Broker Architecture): OMG standard for distributed objects. Uses IDL (Interface Definition Language), ORB (Object Request Broker) for language-agnostic communication.
-
COM (Component Object Model): Microsoft technology for binary software components. Uses GUIDs, registry, IUnknown interface. Language-independent on Windows.
-
DCOM (Distributed COM): Extension of COM for network distribution; uses RPC (Remote Procedure Call).
-
Deployment Diagrams (Frequently Examined)
-
Purpose: Show physical arrangement of hardware nodes and software artifacts (executables, libraries, configurations).
-
Elements:
-
Node: 3D box; represents hardware or software execution environment (e.g.,
Server,Client PC). -
Artifact: Rectangle with
<<artifact>>and folded corner icon (e.g.,app.exe,config.xml). -
Communication Path: Line between nodes; may show protocol (e.g.,
HTTP,TCP/IP).
-
-
Example: Banking Application
-
Nodes:
Web Server,Application Server,Database Server,ATM Client. -
Artifacts:
banking.waron Web Server,banking.jaron App Server,banking.dbon DB Server. -
Paths:
ATM Client↔Web Server(HTTPS),Web Server→App Server(RMI),App Server↔Database Server(JDBC).
-
9. User Interface Design
Designing UIs in OO Context
-
Model-View-Controller (MVC): Separate UI (View) from business logic (Model) and input handling (Controller).
-
OO Principles: Encapsulate UI components as objects; use inheritance for common widgets (e.g.,
Button→RoundButton). -
Patterns: Observer (for event handling), Composite (for nested UI containers).
Principles for ATM UI Design
-
Simplicity: Minimal steps for common tasks (withdraw, balance inquiry).
-
Consistency: Standard button placements, prompts, and error messages.
-
Feedback: Clear responses for every action (e.g., "Please wait...", "Transaction complete").
-
Error Handling: Graceful recovery from invalid inputs (e.g., wrong PIN).
-
Security: Hide sensitive data (mask PIN), auto-logout after inactivity.
-
Accessibility: Large buttons, audio options, clear contrast.
Example ATM Screen Flow:
[Insert Card] → [Enter PIN] → [Main Menu]
Main Menu: [Withdraw] [Balance] [Deposit] [Exit]
Withdraw: [Enter Amount] → [Confirm] → [Dispense Cash] → [Receipt?] → [Take Card]
10. UML Notations Summary
| Symbol | Meaning | Diagram(s) |
|---|---|---|
+ |
Public visibility | Class, Component |
- |
Private visibility | Class, Component |
# |
Protected visibility | Class |
{abstract} |
Abstract class/operation | Class |
{static} |
Static attribute/operation | Class |
<<interface>> |
Interface stereotype | Class, Component |
<<component>> |
Component stereotype | Component |
<<artifact>> |
Artifact stereotype | Deployment |
1, 0..*, 1..* |
Multiplicity | Class, Object |
--> or ← |
Navigability (direction) | Class |
◇ |
Aggregation (shared) | Class |
◆ |
Composition (strong ownership) | Class |
| `— | >` | Inheritance (generalization) |
..> |
Dependency (uses) | Class, Component |
— |
Association | Class, Object |
<<include>> |
Include relationship | Use Case |
<<extend>> |
Extend relationship | Use Case |
* |
Fork/Join (parallel) | Activity |
[guard] |
Condition on transition | Activity, Sequence |
{ordered} |
Ordered property | Class |
[!TIP] Multiplicity Quick Reference:
0..1= optional, single
1= exactly one
*or0..*= zero or more
1..*= one or more
n..m= between n and m (inclusive)
Final Exam Strategy:
-
Memorize diagram purposes (Why use sequence vs. activity?).
-
Practice drawing use case, class (domain), sequence diagrams from scenarios.
-
Distinguish analysis vs. design models clearly.
-
Learn UML notation for multiplicities, relationships, and diagram elements.
-
Compare sequence/collaboration and when not to use activity—these are high-frequency questions.