Software Engineering
Comprehensive exam revision notes for BCA-423E Unit 4 (Software Design Principles, Architecture & Strategies). Includes Section A (2M), Section B (5M), and Section C (15M) questions, answers, and diagrams.
Software Engineering
Software Design Principles, Architecture & Strategies
Core Definitions & Key Concepts
What is the golden rule of modular design regarding Cohesion and Coupling
Software modules should possess High Cohesion (strong internal functional relatedness) and Low (Loose) Coupling (minimal interdependence between modules).
Who formulated the principle of Information Hiding
David L. Parnas in 1972: Modules should encapsulate implementation secrets and data structures behind stable abstract interfaces.
Name the seven levels of Cohesion from lowest (worst) to highest (best)
- Coincidental (worst)
- Logical
- Temporal
- Procedural
- Communicational
- Sequential
- Functional (best)
Name the seven levels of Coupling from tightest (worst) to loosest (best)
- Content Coupling (worst)
- Common Coupling
- External Coupling
- Control Coupling
- Stamp Coupling
- Data Coupling (best)
- Uncoupled
What is McCabe's Cyclomatic Complexity formula
$V(G) = E - N + 2P For a single connected component (P=1), V(G) = E - N + 2 = Pr + 1$ (where $Pr$ is the count of predicate/decision nodes).
What does Cyclomatic Complexity represent for a test engineer
It represents the exact number of linearly independent execution paths through the program, establishing the upper bound on test cases needed for basis path coverage.
Transform Analysis and Transaction Analysis in structured design
- Transform Analysis: Used when DFD shows linear input, central transform, and output streams.
- Transaction Analysis: Used when DFD branches from a transaction dispatcher to parallel specialized action handlers.
The Model-View-Controller (MVC) architectural pattern
- Model: Manages application state and business logic.
- View: Renders user interface.
- Controller: Accepts user inputs and updates Model/View.
Conceptual & Architectural Analysis
The 7 Levels of Cohesion with Real-World Programming Examples
| Cohesion Level | Quality | Description | Concrete Code Example |
|---|---|---|---|
| 1. Functional | Highest (Best) | Module executes single well-defined task | calculate_square_root(x) |
| 2. Sequential | High | Output of one step is direct input to next | parse_file() -> clean_tokens() -> write_output() |
| 3. Communicational | Moderate | Functions operate on same shared data | update_student_record() & print_student_record() |
| 4. Procedural | Moderate | Tasks executed in specific procedural order | check_auth() -> log_attempt() -> read_profile() |
| 5. Temporal | Weak | Grouped because executed at same time | initialize_system() (opens DB, sets fonts, resets timers) |
| 6. Logical | Poor | Grouped by category; uses flag to select | process_all(flag) (if 1 prints, if 2 saves, if 3 emails) |
| 7. Coincidental | Lowest (Worst) | Random arbitrary collection of tasks | misc_utilities() (validates credit card, draws circle) |
The 7 Levels of Coupling with Real-World Programming Examples
| Coupling Level | Quality | Description | Hazard |
|---|---|---|---|
| 1. Data Coupling | Loosest (Best) | Pass atomic primitive parameters (int, str) | Clean, isolated, reusable interfaces |
| 2. Stamp Coupling | Moderate | Pass entire record/struct when only 1 field needed | Module depends on full record layout |
| 3. Control Coupling | Poor | Pass flag directing internal execution branch | Caller must know callee internal control logic |
| 4. External Coupling | Poor | Modules depend on external OS/hardware format | Hardware changes break multiple modules |
| 5. Common Coupling | Very Poor | Multiple modules share global variables | Silent corruption across distant files |
| 6. Content Coupling | Tightest (Worst) | Module directly modifies private data of another | Catastrophic maintenance breakdown |
Structure Chart Notations and Symbols
Structure Chart Elements
- Module Box: Rectangle containing module name.
- Invocation Line: Directed line from parent module pointing to child module.
- Data Couple: Arrow with Open Circle (-\circ\to) denoting data passed.
- Control Couple (Flag): Arrow with Filled Solid Dot (-\bullet\to) denoting status flag.
- Conditional Branch: Diamond symbol at root of invocation arrows.
- Repetitive Loop: Curved semicircular arrow across invocation arrows.
Object-Oriented Design Metrics (CK Metric Suite: WMC, DIT, NOC, CBO, RFC, LCOM)
Chidamber and Kemerer (CK) Metrics
- WMC (Weighted Methods per Class): Sum of complexities of all methods in class. High WMC \implies high maintenance effort.
- DIT (Depth of Inheritance Tree): Max path from root to class. Deep DIT \implies high reuse but complex debugging.
- NOC (Number of Children): Count of direct immediate subclasses.
- CBO (Coupling Between Objects): Count of other classes to which class is coupled. High CBO \implies low reusability.
- RFC (Response for a Class): Methods in class + methods invoked by them.
- LCOM (Lack of Cohesion in Methods): Number of method pairs with zero shared instance variables.
In-Depth Analysis & Implementation
Calculate Cyclomatic Complexity and Derive the Basis Path Test Suite for a Program Code Segment
McCabe's Cyclomatic Complexity Problem Solution
1// Function to classify student grades2void classify_grade(int marks) {3 if (marks >= 40) { // Node 1 (Predicate)4 if (marks >= 75) { // Node 2 (Predicate)5 printf("Distinction"); // Node 36 } else {7 printf("Pass"); // Node 48 }9 } else {10 printf("Fail"); // Node 511 }12} // Node 6 (Exit)1. Construct Control Flow Graph (CFG):
- Nodes: N = 6 (1, 2, 3, 4, 5, 6)
- Edges: E = 7 ((1,2), (1,5), (2,3), (2,4), (3,6), (4,6), (5,6))
- Predicate Nodes: P = 2 (Node 1, Node 2)
2. Cyclomatic Complexity Formulations:
- Formula 1: V(G) = E - N + 2 = 7 - 6 + 2 = \mathbf{3}
- Formula 2: V(G) = P + 1 = 2 + 1 = \mathbf{3}
- Formula 3: Number of enclosed regions + 1 = 2 + 1 = \mathbf{3}
3. Linearly Independent Basis Paths:
- Path 1: 1 \to 5 \to 6 (Input marks = 30 \implies 'Fail')
- Path 2: 1 \to 2 \to 4 \to 6 (Input marks = 60 \implies 'Pass')
- Path 3: 1 \to 2 \to 3 \to 6 (Input marks = 85 \implies 'Distinction')
A test suite executing these 3 paths achieves 100% statement and branch coverage.
Architectural Styles: Layered, Client-Server, Pipe-and-Filter, and Model-View-Controller (MVC) with Diagrams
1. Pipe-and-Filter Architecture
[Raw Stream] ---> | Filter 1 | === Pipe ===> | Filter 2 | === Pipe ===> | Output |
(Lexer) (Parser) (Code Generator)- Decoupled filters process incoming data streams independently (e.g., Unix CLI pipelines).
2. Layered (N-Tier) Architecture
+-------------------------------------------------------+
| Presentation Layer (React / Web UI) |
+-------------------------------------------------------+
|
v
+-------------------------------------------------------+
| Business Logic Layer (Spring Boot / Python Backend) |
+-------------------------------------------------------+
|
v
+-------------------------------------------------------+
| Data Access Layer (Hibernate / SQL ORM) |
+-------------------------------------------------------+
|
v
+-------------------------------------------------------+
| Database Layer (PostgreSQL / Oracle) |
+-------------------------------------------------------+- Each layer interacts strictly with adjacent layers, isolating architectural modifications.
SOLID Object-Oriented Design Principles with Code Demonstrations
The SOLID Principles
- S - Single Responsibility Principle (SRP): A class should have one reason to change.
- O - Open/Closed Principle (OCP): Open for extension, closed for modification.
- L - Liskov Substitution Principle (LSP): Derived types must be substitutable for base types.
- I - Interface Segregation Principle (ISP): Clients should not depend on interfaces they do not use.
- D - Dependency Inversion Principle (DIP): Depend on abstractions, not concretions.
1# Demonstrating OCP and DIP2from abc import ABC, abstractmethod3
4class PaymentProcessor(ABC):5 @abstractmethod6 def pay(self, amount):7 pass8
9class UpiPayment(PaymentProcessor):10 def pay(self, amount):11 print(f"Paid Rs. {amount} via UPI QR.")12
13class CreditCardPayment(PaymentProcessor):14 def pay(self, amount):15 print(f"Paid Rs. {amount} via Credit Card.")16
17# High-level module depends on abstraction (DIP)18class CheckoutService:19 def __init__(self, processor: PaymentProcessor):20 self.processor = processor21 def checkout(self, amount):22 self.processor.pay(amount)Important Exam Points & Quick Revision
Master the 7 levels of cohesion and coupling, McCabe's Cyclomatic Complexity calculation, and SOLID principles.
100% left on this page — finishing it closes the gap for Software Design Principles, Architecture & Strategies.
Software Design Principles, Architecture & Strategies still counts as a weak topic until you finish this note and answer its questions.
Practise this unitTest Your Understanding
Now that you've read through these notes, practice unit MCQs to identify weak points and solidify your learning before exams.