Chapter 5
Instructor: Baber Sheikh (Visiting Faculty)
"The fundamental organization of a system embodied in its elements, their relationships to each other and to the environment, and the principles guiding its design and evolution."
Software Architecture is the bridge between Requirements (What users want) and Implementation (Code we write).
It manages complexity, facilitates communication, and addresses Quality Attributes.
"You likely cannot maximize all quality attributes simultaneously."
Maintainability
Testability
Flexibility
Portability
Performance
Security
Availability
Usability
Time to Market
Cost
Lifetime
Target Market
Customer: Pays for the system. Defines budget, schedule, and business goals.
User: Actually uses the system. Cares about functionality and usability.
Customer wants "Cheap", User wants "Fast".
Architect: Strategic designer. Communicates with stakeholders. Ensures Quality Attributes.
Developer: Tactical builder. Focuses on implementation details and algorithms.
Refined definitions for exam preparation.
| Perspective | Definition & Elements | Connectors | Properties |
|---|---|---|---|
| Static (Code / Dev) |
Compile-time organization
|
Imports, Inheritance, Interfaces | Modularity, Maintainability |
| Runtime (Execution) |
System execution
|
IPC, RPC, Network Calls | Performance, Security, Availability |
| Management (Teams) |
Distribution of work
|
Meetings, Docs, Emails | Cost, Time-to-market |
The core computational units.
Interactions between components.
Rules of the system.
Architecture = Elements (Components + Connectors) + Constraints + Rationale
"Connectors mediate interactions between components."
The standard function call. Caller waits for Callee.
Fire and forget. Notifications.
SQL Queries, File I/O. Accessing shared data stores.
Continuous flow of data (e.g., Video, Audio).
Validates all other views using Use Cases.
End-user functionality
Runtime / Concurrency
Programmers management
System Topology
"No single view is sufficient. We need multiple views to describe a system completely."
System SimpleClientServer = {
Component client = { Port send; };
Component server = { Port receive; };
Connector rpc = {
Role caller;
Role callee;
};
Attachment client.send to rpc.caller;
Attachment server.receive to rpc.callee;
}
Note: UML is a modeling notation, while ADLs are formal languages with strict syntax and semantics for analysis.
Views the entire software system as a series of transformations on successive sets of data.
Each component transforms its Input Data into corresponding Output Data.
"Data moves from one subsystem to another."
(Click to enlarge)
Connections: I/O streams, I/O files, buffers, pipes, etc.
Topology: Graph with cycles, Linear structure, or Tree structure.
No interaction between modules except for input/output data.
Result: High Modifiability & Reusability.
One subsystem can be substituted by another if data format matches.
Can choose either:
Subsystems do NOT need to know the identity of other subsystems.
Applicable in any domain involving well-defined series of independent data transformations.
Traditional data processing model (1950s-1970s). Common in RPG and COBOL.
Figure 5.2: Validation, Sorting, Updating, Reporting
Goal: Validate transactions, sort by primary key (efficiency), update master file.
Note: Intermediate files are transient and can be removed.
Scripts drive the sequence. Data files are the driving force.
< : Input from file (stdin)
> : Output to file (stdout)
Can replace executables (e.g., C program ➔ Java) if input/output formats match.
public class BatchSequential {
public static void main() {
searching(kwd, inputFile, matchedFile);
counting(matchedFile, countedFile);
sorting(countedFile, reportFile);
}
// Static methods belonging to the class, not objects
public static void searching(String kwd, String in, String out) { ... }
public static void counting(String in, String out) { ... }
public static void sorting(String in, String out) { ... }
}
Definition: Decomposes the system into functional components (Filters) connected by data streams (Pipes).
Write Only
Data Source or Filter pushes data downstream.
Read Only
Data Sink or Filter pulls data from upstream.
Read/Write
Filter pulls data from upstream and pushes transformed data downstream.
Serialization: Object-type data must be serialized to pass through binary/char pipes.
💡 Easy Analogy: Water Pump vs. Funnel
Figure 5.4 shows Active Filters connecting to Passive Pipes.
💡 Easy Analogy: Car Assembly Line
Worker A puts on the tires. Worker B installs the engine. Worker B doesn't wait for Worker A to finish all the cars. As soon as one car is ready, Worker B starts. They work at the same time!
Source ➜ Filter 1 ➜ Pipe ➜ Filter 2 ➜ Sink
Lowercase ➔ Uppercase ➔ Match 'A'
💡 Easy Analogy: Empty Plate at Dinner
Blocking Read (Standard): The program halts at read() until
data
arrives.
Non-Blocking: Returns null or 0 immediately if
empty.
|💡 Easy Example: Counting Online Users
Command: who | wc -l
who: Lists everyone logged in.
(Producer)|: The Pipe (Passes the list).wc -l: Counts the lines. (Consumer)
They run together! The counter starts counting before the list follows finished.
Sometimes we need a pipe that stays forever, like a file. That is a Named Pipe (mkfifo).
Concept: Two separate Threads (Programs) running at the same time.
Thread A writes to the pipe. Thread B reads from it.
// WAITER (Filter 1): Puts numbers on the tray
public class Filter1 extends Thread {
PipedWriter pw;
public void run() {
for (int j = 1; j < 100; j++) {
pw.write(j); // Putting data in pipe
}
}
}
// CHEF (Filter 2): Takes numbers off the tray
public class Filter2 extends Thread {
PipedReader pr;
public void run() {
while (pr.read() != -1) {
// Processing data from pipe
}
}
}
💡 Easy Analogy: Cruise Control in a Car
You set the speed to 60mph (Goal). The car checks the speedometer (Sensor). If it's 55mph, it presses the gas (Action). If 65mph, it eases off. It keeps checking and adjusting forever.
Definition: Architecture for embedded systems that maintain a variable (e.g., Temperature, Speed) at a specific level.
Figure 5.9: Feedback Logic
A process control system relies on these key data types:
| Variable Type | Description | Example (AC System) |
|---|---|---|
| Controlled Variable | The target value the system must maintain. | Room Temperature |
| Set Point | The goal value defined by the user. | 72°F (Thermostat Setting) |
| Input Variable | Measured data from sensors. | 78°F (Current Temp) |
| Manipulated Variable | What is adjusted to change the result. | Cold Air Flow / Fan Speed |
The Brain
Calculates the difference:
Error = Set Point - Current Value
Decides how much to adjust.
The Muscle
Physically changes the process control variables (e.g., Engine, Heater, Motor).
Data Flow Architecture decomposes systems into transformation steps connected by data links.
Step-by-step.
Each step completes fully before the next starts.
Example: Month-end billing.
Concurrent Streaming.
Steps run in parallel. Data flows constantly.
Example: Unix Command Line.
Continuous Feedback.
Maintains a state using loops.
Example: Cruise Control.
| Feature | Batch Sequential | Pipe & Filter | Process Control |
|---|---|---|---|
| Data Flow | Discrete Batches | Continuous Streams | Variable Updates |
| Control | Explicit (Step A then B) | Implicit (Driven by Data) | Loop (Driven by Sensors) |
| Concurrency | None (Sequential) | High (Parallel) | Real-time |
| Best For | Tape/File Processing | Media/Text Streams | Embedded Systems |
💡 How to design a Data Flow System?
Follow these 4 golden rules:
Data Flow architecture is not about objects or functions. It's about Movement.
🎓 Crux: Choose Batch for simplicity, Pipes for speed, and Control for physical feedback.
Use this decision logic for your projects:
"I have a massive file. I need to calculate statistics. Precision is key. Time is not critical."
👉 Use Batch Sequential
"I am building a live video editor. Users apply effects while the video plays."
👉 Use Pipe & Filter
"I am programming a drone to hover at a specific altitude."
👉 Use Process Control
We will simulate a Pipe & Filter system manually.
End of Week 4: Data Flow Architectures
Questions?