Orthogonal Code

Orthogonal Code#

Idea:

Two components are orthogonal if changing one does not affect the other.

Benefits
  • Run parts of your analysis in isolation

  • Bugs stay contained to one component

  • Reuse components across projects

  • Write tests for one module without mocking the rest

Trade-offs
  • More upfront planning required

  • Execution flow can be harder to trace

  • Over-splitting leads to fragmentation

Example: Computation vs. Visualization#

Non-orthogonal

Clustering and plotting mixed in the same loop. Want to change a plot color? Re-run the clustering.

Orthogonal

Separate the computation from the visualization. Store results, then plot independently. Change colors without re-running a 3-day computation.