Coupling measures the interdependence between modules. We aim for **low coupling** (ideally Data Coupling) to improve maintainability, reusability, and testability.
What is a Data Flow Diagram (DFD)?
A Data Flow Diagram (DFD) is a graphical representation of the flow of data through an information system. It shows how data enters and leaves the system, what changes the information, and where data is stored.
DFDs are used to visualize the major functions of a system and the data relationships between them.
Components of a DFD
Process: A function that transforms data. Represented by a circle or a rounded rectangle.
Data Flow: The movement of data between processes, external entities, and data stores. Represented by an arrow.
External Entity (Terminator): A source or destination of data outside the system. Represented by a rectangle.
Data Store: A place where data is held or stored. Represented by two parallel lines or an open-ended rectangle.
DFD Levels: Context Diagram (Level 0)
The Context Diagram, also known as Level 0 DFD, is the highest-level view of a system. It shows the entire system as a single process, along with its interactions with external entities.
It defines the boundaries of the system.
It shows the major inputs and outputs of the system.
It does not show any internal details of the system.
Example: Online Shopping System - Context Diagram (Level 0)
graph TD
Customer[Customer] -- Order Info, Payment Info --> ProcessOrder(Online Shopping System)
ProcessOrder -- Order Confirmation, Product Info --> Customer
PaymentGateway[Payment Gateway] -- Payment Details --> ProcessOrder
ProcessOrder -- Payment Status --> PaymentGateway
InventoryManager[Inventory Manager] -- Stock Info --> ProcessOrder
ProcessOrder -- Inventory Update --> InventoryManager
DFD Levels: Level 1 Diagram
The Level 1 DFD provides a more detailed view of the system by breaking down the single process from the Context Diagram into its major sub-processes.
It shows the main functions within the system.
It illustrates the data flows between these internal processes, external entities, and data stores.
It maintains consistency with the Context Diagram (inputs and outputs must match).
Example: Online Shopping System - Level 1 Diagram
graph TD
Customer[Customer] -- Order Info --> P1(Process Order)
P1 -- Order Confirmation --> Customer
P1 -- Order Details --> DS1[Order Database]
DS1 -- Order Details --> P2(Process Payment)
Customer -- Payment Details --> P2
P2 -- Payment Status --> Customer
P2 -- Payment Details --> PaymentGateway[Payment Gateway]
PaymentGateway -- Payment Status --> P2
P2 -- Inventory Update --> P3(Manage Inventory)
P3 -- Stock Status --> InventoryManager[Inventory Manager]
InventoryManager -- Stock Query --> P3
P3 -- Product Info --> DS2[Product Database]
DS2 -- Product Info --> Customer
Advantages of DFDs
Clarity: Easy to understand and visualize the flow of data.
Communication: Effective tool for communication between users and developers.
Analysis: Helps in identifying missing data, redundant data, and incorrect processes.
Hierarchical: Can be decomposed into multiple levels for detailed understanding.
Disadvantages of DFDs
No Control Flow: Does not show the sequence of operations or decision logic.
No Timing Information: Does not show when processes occur.
Can Be Complex: For very large systems, DFDs can become cluttered and difficult to read.
Requires Expertise: Creating effective DFDs requires skill and experience.
Key Takeaways
**DFDs** graphically represent data flow in a system.
Key components are **processes, data flows, external entities, and data stores**.
**Context Diagram (Level 0)** shows the system as a single process.
**Level 1 DFD** breaks down the system into its major sub-processes.
DFDs are excellent for **visualizing data movement** but don't show control flow or timing.