Software Engineering Principles and Practices / Software Architecture

System Decomposition

System Decomposition (also known as functional or modular decomposition) is the process of breaking a complex system into smaller, more manageable, and independent sub-systems or components. It is the "Divide and Conquer" strategy of Software Engineering.

The goal is to transform a giant, overwhelming problem into a set of small, solvable tasks.


⚙️ Why Decompose?

Without decomposition, you have a Monolithic mess. Decomposition provides:

  • Manageability: Smaller parts are easier to understand and code.

  • Parallel Development: Different teams can work on different components simultaneously.

  • Maintainability: If a bug occurs in the "Payment" component, you know exactly where to look.

  • Reusability: A well-decomposed "Logging" component can be used in five different projects.


🧱 Levels of Decomposition

Decomposition happens in layers, moving from the abstract to the concrete:

  1. System Level: The entire application (e.g., An E-commerce Platform).

  2. Subsystem Level: Major functional areas (e.g., Inventory Management, User Authentication, Order Processing).

  3. Module/Component Level: Specific logical units (e.g., Credit Card Validator, Email Formatter).

  4. Class/Routine Level: The actual code objects and functions.


🛠️ Common Decomposition Strategies

1. Functional Decomposition

The system is broken down based on what it does (actions).

  • Example: A Library System is decomposed into "Search Book," "Issue Book," and "Return Book."

2. Object-Oriented Decomposition

The system is broken down based on real-world entities (nouns).

  • Example: An ATM system is decomposed into "Account," "Card Reader," "Cash Dispenser," and "Transaction."

3. Data-Oriented Decomposition

The system is structured around the data it processes. This is common in "Big Data" or database-heavy applications where the flow of information dictates the boundaries.


📐 The "Good" Decomposition Criteria

How do you know if you've decomposed a system correctly? You look at two metrics we discussed earlier:

  • High Cohesion: Each decomposed part should have a single, well-defined purpose.

  • Low Coupling: The parts should have minimal dependencies on each other. If you move "Component A," "Component B" shouldn't fall over.

💡 The Rule of Seven: A common heuristic in software design suggests that a human mind can only track about $7 \pm 2$ things at once. If your decomposition results in 50 modules at the same level, it's too complex—you need another layer of sub-systems.


📊 Decomposition Example: Smart Home System

Level

Component

Responsibility

Top

Smart Home App

User Interface and Main Control.

Middle

Lighting Subsystem

Manages all bulbs and dimmers.

Middle

Security Subsystem

Manages cameras and motion sensors.

Bottom

Motion Sensor Module

Detects movement and sends a signal.


⚠️ The Danger: Over-Decomposition

You can break things down too much. If every single line of code is its own "module," you create "Granularity Overhead." This makes the system hard to follow because of the sheer number of connections and interfaces required to make the pieces talk.