Skip to content
tezvyn:
Menu

When to formalize a cross-cutting concern?

Source: Wikipedia: Cross-cutting concernHardHow cards are made

Tests your judgment on architectural trade-offs. A good answer uses the "Rule of Three," weighs volatility and complexity to decide, and avoids dogmatic DRY. A red flag is immediately abstracting without considering the high cost of a shared solution.

What's really being asked

This question probes your senior-level judgment on architectural trade-offs, specifically the tension between DRY principles and the costs of coupling. It tests if you can apply a nuanced decision-making framework in an agile, emergent design context, rather than applying a dogmatic rule. The interviewer is looking for your understanding of volatility, risk, and the organizational costs of shared code.

The full answer

A strong answer presents a decision-making framework. First, acknowledge the "Rule of Three" as a starting point: tolerate duplication until the third instance appears. Second, introduce the core decision criteria for moving to a shared solution: high volatility (the logic changes often), high complexity or risk (e.g., authentication, payments), or a high cost of inconsistency across teams. Third, contrast this with when duplication is acceptable: low volatility, low risk, and when the overhead of a shared solution (ownership, versioning, distribution) outweighs the benefits. Fourth, describe the process of introducing a shared solution, such as a timeboxed spike and clear ownership.

The mistakes people make

A major red flag is a dogmatic, one-size-fits-all answer. "You should always abstract to avoid duplication" is a junior answer that ignores the high cost of premature abstraction, coupling, and cross-team dependencies. Another red flag is the opposite: "Shared libraries are always bad." This ignores the massive maintenance burden of updating a critical, scattered concern (like a security patch) in dozens of places. A weak answer also fails to mention the organizational aspect (Conway's Law) and the cost of coordination.

What usually comes next

"Describe a time you argued for duplication. What was the outcome?" "How do you manage the lifecycle and versioning of a shared library once it's created?" "What if the teams can't agree on a common interface for the shared solution?"

A concrete example

Imagine three microservices all needing to report metrics. Initially, each team implements a simple client for a metrics backend. This is fine. But then, we need to add standardized labels (e.g., region, cluster_name) to every metric for a new observability platform. The requirement is volatile and consistency is critical. Updating all three services is slow and error-prone. This is the trigger to invest in a shared, versioned metrics library that handles the standardized labeling, which the three teams can now adopt. The cost of coordinating the library is now less than the cost of mis-implementing or forgetting the labels.

Interview question

When deciding whether to formalize a cross-cutting concern, what is the primary architectural trade-off to evaluate?

  • a.Strict adherence to the DRY principle versus the initial development time for a shared library.
  • b.The number of times the logic is duplicated, based on the 'Rule of Three'.
  • c.The performance of duplicated inline code versus the potential latency of a shared service call.
  • d.The risk and cost of inconsistent implementations versus the coupling and coordination overhead of a shared solution.Correct
Why?

The core decision is a trade-off between the ongoing cost/risk of managing duplicated logic (especially if it's volatile or complex) and the cost of creating and maintaining a shared, coupled solution. The 'Rule of Three' is a helpful starting heuristic, not the primary trade-off itself.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on architecture — each one lists the topics its interview covers.

See open roles