Loading...
Loading...
Browse 5 real-world technical and behavioral interview questions about Coupling. Review scenarios, edge cases, and architectural best practices.
Adapter converts a type you do not own into the interface your code already speaks. Decorator adds behaviour while keeping the same interface, so wrappers stack. Facade gives callers one narrow entry point into a subsystem. Each becomes over-engineering the moment nothing on the other side varies.
Observer decouples a subject from things that react to it, which is right when the subject genuinely should not know its listeners. The costs are a control flow you cannot read from the code, listener lifetimes that leak, and an exception in one observer that silently prevents the rest from running.
Name the single writer first, then choose which coupling you would rather own: a shared schema couples the two teams' release calendars, while a replicated copy couples them to a staleness window and obliges someone to detect and repair divergence. Both are permanent, so pick the one your organisation can pay for.
A class violates SRP when it has more than one reason to change, not when it has more than one method; the refactor is to split along the axes that have independently churned, such as pricing rules, persistence, and presentation, and to stop splitting once each piece has its own requester.
A synchronous call couples availability and latency but keeps the outcome knowable at the point of decision; an event decouples both but converts every failure into something the caller will never learn about. Choose by asking whether the caller needs the answer to proceed, not by which style is fashionable.