A bad pattern - temporal decomposition

Take away

Design modules based on the knowledge needed for each task, not the order of operations, to prevent information leakage.

Way

temporal decomposition is a bad design style where the structure of a system is organized based on the sequence of operations that occurs over time. Essentially, it's dividing the system into parts that correspond to the steps in a process, in the order they happen.

Examples - file read and write

an application that:

  1. reads a file in a particular format
  2. modifies the contents of the file
  3. then writes the file out again.

which results to information leakage .

Q: Why ?
A: Both the file reading and writing components need to know the file format. This shared knowledge about the file format between different classes

Examples - an e-commerce example

an application that:

  1. order processor - take an order from a customer.
    • It knows about the order detailed and how to calculate the total price.
  2. payment gateway - handles the payment processing.
    • It receives the order total from order processor and interacts with a payment gateway to complete the transaction.
  3. order confirm to sender - sends a confirmation email to customer after the payment is success.
    • it receives the order detailed from order processor

both order processor and order confirm to sender know about the payment detail, which tightly coupling them that it's hard to modify or extend

Recommendations