
B
AAt companies like Stripe, engineers often work in codebases that must evolve without becoming fragile. Design patterns matter because they provide proven ways to structure code for change, testing, and collaboration.
Explain the role of design patterns in building maintainable software.
Address these points:
The interviewer expects a practical software engineering explanation rather than a memorized catalog of patterns. You should discuss trade-offs, give 2-3 concrete examples such as Strategy, Factory, or Observer, and connect them to maintainability concerns like extensibility, testability, readability, and change isolation.
A core reason to use design patterns is to isolate parts of the system that are likely to change. Instead of scattering conditional logic or object creation rules across the codebase, patterns centralize those decisions so future updates affect fewer files.
class PaymentStrategy:
def pay(self, amount):
raise NotImplementedError
Many patterns reduce direct dependencies between components. Lower coupling makes code easier to test, replace, and reason about because one module can evolve without forcing changes in unrelated modules.
class Notifier:
def send(self, message):
raise NotImplementedError
Patterns often reinforce single responsibility by giving each class or object a focused role. This improves readability and makes maintenance easier because developers know where behavior belongs.
A good pattern allows new behavior to be added by introducing new classes or implementations rather than modifying stable code. This aligns with the Open/Closed Principle and reduces regression risk.
class CreditCardPayment(PaymentStrategy):
def pay(self, amount):
return f'Paid {amount} by card'
Patterns are tools, not goals. Applying them too early or too rigidly can create unnecessary abstraction layers, making simple systems harder to understand and maintain.