Skip to content
tezvyn:
Menu

When should cross-cutting concerns use a shared versus duplicated solution?

Source: Wikipedia: Cross-cutting concernHardHow cards are made

Summary

Judging coupling versus duplication in emergent design.

Key points

Weigh change frequency and blast radius; decide via fitness function or ADR, not default shared code.

Watch out for

Mandating one shared library for all cross-cutting concerns.

What's really being asked

The interviewer is probing whether you treat architecture as an emergent property rather than a predefined blueprint. Specifically, they want to see you recognize that cross-cutting concerns such as logging, authentication, or metrics inherently resist clean encapsulation within a single module. They are listening for your ability to evaluate the tension between DRY principles and the coupling introduced by shared infrastructure, particularly in polyglot or multi-team environments where deployment independence and team autonomy matter.

The full answer

Four elements in order. First, an explicit cost model that compares the friction of duplication against the friction of coordination. Second, concrete evaluation criteria such as change frequency, blast radius if the shared component fails, team topology and Conway's Law implications, and whether the concern is truly invariant or varies by domain. Third, a decision mechanism like an Architecture Decision Record or a fitness function that forces the team to re-evaluate the choice as the system evolves rather than treating it as permanent. Fourth, the recognition that shared solutions create platform teams or dependency graphs that can become bottlenecks, so you should default to duplication when teams are autonomous and services are independently deployable, then extract a shared solution only when pain data justifies it.

The mistakes people make

Three red flags stand out. One, defaulting immediately to a shared library or framework because duplication feels wrong without measuring the coordination overhead. Two, ignoring team topology and forcing every service to use a centralized auth or logging platform even when teams have different release cycles or tech stacks. Three, confusing a cross-cutting concern with a core domain concept; if authentication is a business differentiator, it deserves different treatment than commodity logging.

What usually comes next

The interviewer may ask how you would migrate from duplicated implementations to a shared one safely, how you version a shared authentication client without breaking downstream consumers, or how you handle a cross-cutting concern that scatters logic but cannot be cleanly extracted due to tangling with domain code.

A concrete example

Suppose three microservices initially implement request logging independently using their respective language idioms. After six months, observability requirements converge and operators struggle with inconsistent trace formats. You propose a lightweight shared logging schema and a thin wrapper, but only after measuring that the duplicated parsing code now costs more in incident response time than the overhead of versioning one shared library. You keep the transport layer decoupled so teams can still adopt it asynchronously.

Interview question

When should autonomous teams running independently deployable services choose a shared solution for a cross-cutting concern?

  • a.As soon as the concern appears in multiple services to prevent duplication and keep code DRY
  • b.Once the services' requirements for that concern converge enough to justify strict standardization
  • c.Only after a centralized platform team is formed to maintain the shared library and enforce adoption
  • d.When measured pain data shows duplication costs exceed the coordination overhead of sharingCorrect
Why?

The card states that autonomous teams should default to duplication and extract a shared solution only when pain data justifies it, such as when incident response costs from inconsistent implementations exceed the overhead of versioning a shared library. Option A is a red flag because it advocates for shared code purely to satisfy DRY without weighing the coordination friction, blast radius, or team topology.

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. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles