PadhaikoAll subjects

System Modeling (part 1: 5.1–5.2)

Software Engineering (ENCT 352)

Open in the Padhaiko app

5.1 System modeling

Definition

System Modeling

System modeling is the process of developing abstract, graphical, and textual representations of a software system from multiple complementary perspectives before writing implementation code.

According to Sommerville, a complete understanding of a software system requires modeling it from four complementary perspectives:

  1. External Perspective (Context): Models the system boundaries and the external entities (users, hardware, other systems) in its operating environment.
  2. Interaction Perspective: Models interactions between the system and its environment, or among components inside the system (e.g., use cases, sequence diagrams).
  3. Structural Perspective: Models the static organization of data or architectural components (e.g., class diagrams, entity-relationship models).
  4. Behavioral Perspective: Models dynamic system behavior and how the system responds to internal or external events (e.g., activity diagrams, state diagrams, DFDs).

5.1.1 Need for system modeling

Building a complex software system directly from prose requirements invites ambiguity, missed edge cases, and costly architectural rework. System models are essential for five reasons:

  1. Clarifying Requirements & Reducing Ambiguity: Visual diagrams expose missing inputs, contradictory rules, and unstated assumptions far more quickly than pages of English text.
  2. Facilitating Stakeholder Communication: Simplified visual models bridge the communication gap between non-technical domain experts and software engineers.
  3. Analyzing Completeness & Consistency Early: Engineers can trace every input, output, data store, and state transition before committing coding effort—where defects cost less to fix than in production.
  4. Guiding Architectural & Detailed Design: Models serve as the structural blueprint from which modules, database schemas, and API contracts are derived.
  5. Providing Living Documentation: Well-maintained models accelerate onboarding for new developers and simplify future system maintenance.

5.1.2 Role of abstractions in managing complexity

Human short-term memory can track only a handful of concepts simultaneously (Miller's rule). Large enterprise or embedded systems contain thousands of interacting functions and states—impossible to reason about all at once.

Definition

Abstraction in System Modeling

Abstraction is the selective suppression of irrelevant low-level details so engineers can focus exclusively on the essential concepts and relationships relevant at the current level of analysis.

Abstraction manages complexity through three complementary mechanisms:

  1. Hierarchical Decomposition (Leveling): A monolithic problem is broken into coarse top-level views (e.g., Level-0 Context Diagram) and progressively refined into detailed lower-level diagrams (Level-1, Level-2), keeping each diagram readable (typically processes per view).
  2. Selective Perspective Filtering: Rather than forcing structure, data flow, and timing onto a single cluttered chart, each diagram abstracts away other concerns (e.g., a class diagram hides runtime control flow; a DFD hides memory layout and loop counters).
  3. Encapsulation & Interface Contracts: Treating a complex subsystem as a black-box component with defined inputs and outputs allows higher-level models to reason about system behavior without inspecting internal code.

5.2 Process modeling using DFD

Definition

Data Flow Diagram (DFD)

A Data Flow Diagram (DFD) is a graphical process-modeling technique that represents how data flows through a system, the processes that transform the data, the external entities that supply or consume data, and the data stores where information rests.

Unlike flowcharts—which show control flow (loops, if/else branching, execution order)—a DFD shows data flow (data transformations and dependencies) without specifying timing or execution sequence.

AspectData Flow Diagram (DFD)Flowchart
Primary FocusFlow and transformation of data across processesSequence of control (decisions, loops, step order)
Execution ModelProcesses can operate concurrently whenever input data is readyStrictly sequential, one execution arrow active at a time
Data PersistenceExplicitly represents persistent data storesDoes not model persistent files or database stores separately
Phase UsedRequirements analysis & structured system modelingDetailed algorithm and procedural logic design

The Four Standard DFD Symbols

Standard DFD Components (Yourdon/DeMarco vs. Gane–Sarson)
ComponentMeaningNaming RuleYourdon / Gane–Sarson Shape
1. External Entity (Source / Sink)Person, organization, or external system outside the system boundary supplying or receiving dataSingular noun phrase (e.g., Student, Bank Gateway)Rectangle / Square (often shaded)
2. Process (Bubble)Business activity or software function that transforms incoming data flows into outgoing data flowsVerb + Object phrase (e.g., Validate Login, Compute Fine)Circle (Yourdon) or Rounded Rectangle (Gane–Sarson)
3. Data FlowPipeline carrying packets of data in motion from source to destinationDescriptive noun phrase (e.g., Course Request, Fee Receipt)Directed arrow ()
4. Data StoreRepository holding data at rest between processes (files, database tables)Plural noun phrase (e.g., D1: Student Records)Open-ended rectangle / Parallel lines

DFD Leveling (Context, Level 1, and Level 2)

DFDs use hierarchical abstraction so complex systems stay comprehensible:

Level-0 Context Diagram vs. Level-1 DFD: Online Library BorrowingText
LEVEL 0 (CONTEXT DIAGRAM):
+----------+    Book Request     +-------------------+    Borrow Receipt    +-----------+
| Student  | ------------------> |  0. Library       | -------------------> |  Student  |
+----------+                     |  Management Sys   |                      +-----------+
                                 +-------------------+
                                           | Overdue Notice
                                           v
                                    [ Notification ]

LEVEL 1 DFD (DECOMPOSED):
+----------+  Loan Req   ( 1.0 Verify )  Valid Req   ( 2.0 Issue )  Receipt  +---------+
| Student  | ----------> (   Member   ) -----------> (   Book    ) --------> | Student |
+----------+             (____________)              (___________)           +---------+
                                |                          |  ^
                       Read     v                  Update  v  | Book Status
                         +---------------+           +---------------+
                         | D1 | Members  |           | D2 | Books    |
                         +---------------+           +---------------+

Essential Rules for Drawing Valid DFDs

  1. No Black Holes: Every process must have at least one input data flow and at least one output data flow (a process with inputs only is a black hole).
  2. No Miracles: A process cannot create output data flows out of nothing (no inputs = miracle).
  3. No Direct Entity-to-Entity or Store-to-Store Flows: External entities cannot talk directly to each other or directly to a data store without passing through a process.
  4. Conservation / Balancing Rule: When decomposing a parent process at Level into a Level- child diagram, the net external inputs and outputs entering/leaving the child diagram must match the exact inputs and outputs of parent process .
  5. Logical vs. Physical DFD: A logical DFD models what the business does (independent of tech: "Verify Payment"), whereas a physical DFD models how it is implemented ("Stripe_REST_Worker.py", "MySQL_Users_Table").

Worked Examples

Example 5.1

5.1

Construct a Level-0 Context Diagram and a Level-1 DFD for a University Course Enrollment System where:

Verify that your Level-1 diagram balances with your Level-0 Context Diagram.

Identify External Entities, Data Stores, and Boundary Flows:

  • External Entities: Student, Administrator.
  • Incoming Boundary Flows: Registration Request (from Student), Course Catalog (from Administrator).
  • Outgoing Boundary Flows: Enrollment Confirmation, Rejection Notice (to Student), Enrollment Reports (to Administrator).
  • Internal Data Stores (Level 1 only): D1: Courses, D2: Enrollments.

Level-0 Context Diagram:

Level-0 Context Diagram: Course Enrollment SystemText
+---------+  Registration Request   +------------------------+  Course Catalog   +---------------+
| Student | ----------------------> |  0. Course Enrollment  | <---------------- | Administrator |
+---------+                         |        System          | ----------------> +---------------+
     ^                              +------------------------+  Enrollment Reports
     |   Enrollment Confirmation /               |
     +------------- Rejection Notice ------------+

Level-1 DFD and Balancing Check:

Level-1 DFD: Course Enrollment SystemText
+---------------+  Course Catalog   ( 1.0 Manage    )  Write   +---------------+
| Administrator | ----------------> (   Catalog     ) -------> | D1 | Courses  |
+---------------+                   (_______________)          +---------------+
        ^                                                              | Seat Count
        | Enrollment Reports                                           v
( 3.0 Generate  ) <----- Read Enrollments --- +-------------------+ <--+
(    Reports    )                             | D2 | Enrollments  |
(_______________)                             +-------------------+
                                                        ^
+---------+  Registration Request   ( 2.0 Process   ) --+ Write Enrollment
| Student | ----------------------> (   Enrollment  )
+---------+ <---------------------- (_______________)
             Confirmation / Rejection

Balancing Verification:

  • Context inflows (Registration Request, Course Catalog) match Level-1 inflows entering processes 2.0 and 1.0.
  • Context outflows (Enrollment Confirmation, Rejection Notice, Enrollment Reports) match Level-1 outflows leaving processes 2.0 and 3.0.
  • Every process has both inputs and outputs, and no external entity touches a data store directly.
Answer:

The Level-0 Context Diagram captures boundary interactions with Student and Administrator, and the Level-1 DFD decomposes the system into 1.0 Manage Catalog, 2.0 Process Enrollment, and 3.0 Generate Reports connected via D1: Courses and D2: Enrollments while preserving exact boundary-flow balance.

Example 5.2

5.2

During a DFD decomposition audit for an e-commerce order system, a Level-0 Context Diagram has boundary data flows: inflows (Order Details, Payment Confirmation) and outflows (Invoice, Dispatch Instruction). When decomposed into a Level-1 DFD with processes (1.0 Validate Order, 2.0 Process Payment, 3.0 Fulfill Order) and data stores (D1: Inventory, D2: Orders), the analyst counts:

  1. Compute the total number of internal flows (process-to-process + data-store flows) and total flows on Level 1.
  2. Identify the DFD balancing violation and explain how to fix it.

Part 1 — Flow Count Verification:

  • Process-to-process flows .
  • Data-store flows .
  • Total internal flows (equivalently ).
  • Total boundary flows present on Level 1 .
  • Total data flows on Level 1 .

Part 2 — Diagnose and Fix the Balancing Violation:

To fix the violation, either add external entity Warehouse Manager and outflow Low Stock Alert to the Level-0 Context Diagram (if alerts are truly in scope), or remove Low Stock Alert from Level 1 if it is out of scope.

Answer:
  1. Level 1 contains internal flows and boundary flows ( flows total).
  2. Balancing Violation: Low Stock Alert to Warehouse Manager exists on Level 1 without appearing on Level 0; resolve by adding Warehouse Manager and Low Stock Alert to the Level-0 Context Diagram (or removing it if out of scope).
Example 5.3

5.3

How to Answer a Past Exam Question: "Explain the role of abstraction in managing software complexity, and contrast Logical vs. Physical DFDs with a concrete example."

Part 1 — Abstraction and Complexity Management: Define abstraction (suppressing irrelevant details), cite cognitive limits, and explain three concrete mechanisms: hierarchical leveling (Level 0 Level 1 Level 2), multiple orthogonal viewpoints (process vs. data vs. state), and encapsulation/black-box interfaces.

Part 2 — Logical vs. Physical DFD Comparison: Give a side-by-side example for the same operation (e.g., student fee payment):

  • Logical DFD: Process Verify Fee Payment, flow Payment Details, store Student Ledger (technology-independent, used in analysis).
  • Physical DFD: Process payment_worker.py (Port 8443), flow JSON_PayPayload, store PostgreSQL_fees_tbl (implementation-specific, used in design).
Answer:

A top-scoring answer pairs hierarchical leveling, perspective separation, and encapsulation under abstraction with a side-by-side Logical vs. Physical DFD illustration showing what happens versus how/where it executes.


Exercises

Practice Exercises — System Modeling & DFD

Question 1

What is system modeling? Describe the four modeling perspectives used to understand a software system and explain four reasons why system modeling is needed before coding.

System Modeling & Four Perspectives: System modeling builds abstract graphical representations of a system from four perspectives:

  1. External Perspective: Defines system context and external boundaries.
  2. Interaction Perspective: Shows communication between users/systems and internal components.
  3. Structural Perspective: Captures static data and component organization.
  4. Behavioral Perspective: Depicts dynamic data processing and event responses.

Four Reasons System Modeling Is Needed:

  1. Exposes ambiguity and missing requirements early.
  2. Facilitates clear communication with non-technical stakeholders.
  3. Enables early consistency/completeness verification at low cost.
  4. Guides architectural/database design and documents the system for future maintainers.
Answer:

System modeling creates abstract representations across external, interaction, structural, and behavioral perspectives to clarify requirements, align stakeholders, detect design flaws early, and provide lasting system documentation.

Question 2

Explain how abstraction helps manage software complexity in system modeling, and describe the role of hierarchical leveling in keeping diagrams readable.

Role of Abstraction: Abstraction hides irrelevant implementation details (such as memory addresses, loop counters, or framework boilerplate) so analysts can reason clearly about essential behavior at a given scope without exceeding human cognitive limits.

Hierarchical Leveling: Hierarchical leveling starts with a single high-level overview (e.g., a Context Diagram) and decomposes complex nodes step by step into lower-level diagrams ( nodes per view), allowing engineers to study either the big picture or fine details without clutter.

Answer:

Abstraction suppresses irrelevant low-level detail so engineers focus on essential structure and behavior. Hierarchical leveling decomposes complex systems into bounded, multi-level views (Level 0, Level 1, Level 2) that keep each diagram clean and understandable.

Question 3

List the four basic symbols of a Data Flow Diagram (DFD), compare a DFD against a Flowchart, and state four rules that every valid DFD must satisfy.

Four DFD Symbols:

  1. External Entity: Source or sink outside the system boundary.
  2. Process: Function transforming input data flows into output data flows.
  3. Data Flow: Directed pathway of moving data packets.
  4. Data Store: Persistent repository holding data at rest.

DFD vs. Flowchart & Four Validity Rules: A DFD models data transformations and allows concurrent processes, whereas a Flowchart models sequential control flow (decisions and loops). Four rules: (1) No black holes (process needs output), (2) No miracles (process needs input), (3) No direct entity-to-entity or entity-to-store links without a process, and (4) Parent-child balancing of boundary flows.

Answer:

DFDs use external entities, processes, data flows, and data stores to model data transformation (unlike flowcharts, which model sequential control). Valid DFDs avoid black holes, miracles, unmediated entity/store links, and parent-child balancing mismatches.

Question 4

Draw (in structured text/diagram form) a Level-0 Context Diagram and a Level-1 DFD for an ATM Cash Withdrawal System involving a Customer and a Bank Core Server.

Level-0 Context Diagram:

  • External entities: Customer, Bank Core Server.
  • Process 0. ATM System: receives Card + PIN and Withdrawal Amount from Customer, sends Account Query / Debit Request to Bank Core Server, receives Auth / Balance Response, and outputs Cash + Receipt (or Error Message) to Customer.

Level-1 DFD:

  • 1.0 Authenticate User: verifies Card + PIN with Bank Core Server.
  • 2.0 Check Balance & Dispense Cash: validates funds against Bank Core Server and D1: ATM Cash Cassette, updates cassette inventory, and outputs Cash.
  • 3.0 Print & Log Transaction: writes transaction record to D2: Transaction Log and issues Receipt to Customer.
Answer:

The Level-0 Context Diagram wraps the ATM as one process between Customer and Bank Core Server, and the Level-1 DFD decomposes it into 1.0 Authenticate User, 2.0 Check Balance & Dispense Cash, and 3.0 Print & Log Transaction backed by D1: ATM Cash Cassette and D2: Transaction Log.

Question 5

Suppose a large Hospital Information System is modeled using hierarchical DFDs where the single Level-0 process decomposes into Level-1 processes, each Level-1 process decomposes into Level-2 processes, and each Level-2 process decomposes into Level-3 leaf processes.

  1. Compute the number of Level-3 leaf processes and the total number of processes across Levels and .
  2. Explain why this balanced hierarchical decomposition is far more maintainable than drawing all leaf processes on a single diagram.

Part 1 — Process Count Across Levels:

  • Level 0: process.
  • Level 1: processes.
  • Level 2: processes.
  • Level 3 (leaf processes): processes.

Part 2 — Why Hierarchical Abstraction Matters: Drawing leaf processes and their hundreds of data flows on one flat canvas creates an unreadable tangle. Keeping each diagram to processes respects cognitive limits, lets stakeholders inspect high-level workflows on Level 1, and restricts detailed edits to one localized Level-2/Level-3 sub-diagram without breaking global comprehension.

Answer:
  1. There are Level-3 leaf processes and total processes across Levels .
  2. Hierarchical decomposition keeps every diagram to a readable processes, isolating complexity and localizing maintenance changes.
← Architectural DesignSystem Modeling (part 2: 5.3–5.4) →