OOP and Design Patterns interview questions
100 Backend Engineering practice questions. Read what a strong answer covers, then practise it out loud against the clock.
Practise OOP and Design Patterns questionsBeginner
- A 3,000-line service class
- Abstraction explained
- Adding logging and metrics to many methods
- Class impossible to unit test
- Composition over inheritance
- Constructor with 12 parameters
- Deep inheritance hierarchy is hard to change
- Dependency injection
- Dependency inversion principle
- DRY, KISS and YAGNI
- Encapsulation explained
- Growing if-else for payment methods
- Inheritance explained
- Integrating an SDK with a different interface
- Interface segregation principle
- Interfaces vs abstract classes
- Liskov substitution principle
- Magic numbers and unclear names
- Open/closed principle
- OrderService calls every module directly
- Polymorphism explained
- Same validation logic copied in five places
- Single responsibility principle
- SOLID principles overview
- Subclass breaks code that uses the parent
- Tests interfere with each other through a singleton
- The adapter pattern
- The builder pattern
- The decorator pattern
- The factory pattern
- The four pillars of OOP
- The observer pattern
- The singleton pattern
- The strategy pattern
Intermediate
- Adding notification channels keeps getting harder
- Business logic inside controllers
- Chain of responsibility
- Clean architecture
- Code full of unnecessary patterns
- Cohesion and coupling
- Entities vs value objects
- Every endpoint repeats the same checks
- Expensive client created on every startup
- Hexagonal architecture
- Interface with 20 methods
- Long chains of method calls
- Many callers use a complex subsystem incorrectly
- Modelling discounts with inheritance or composition
- Money stored as floating-point numbers
- Null checks everywhere
- Null object and Optional
- Operations need to be queued and retried
- Order status logic scattered everywhere
- ORM annotations everywhere in business logic
- Refactoring legacy code without tests
- Report generators with duplicated steps
- Rich vs anemic domain models
- The command pattern
- The facade pattern
- The Law of Demeter
- The proxy pattern
- The repository pattern
- The service layer
- The state pattern
- The template method pattern
- The unit of work pattern
- Two modules depend on each other
Experienced
- Aggregate too large causes contention
- Aggregates as consistency boundaries
- CQRS at the code level
- Database details leaking into the domain
- Designing a discount rules engine
- Designing a logging framework
- Designing a pluggable payment module
- Designing a reusable retry utility
- Designing a reusable state machine for workflows
- Designing code for testability
- Domain events in application code
- Feature flag conditionals everywhere
- Functional vs object-oriented design in backends
- Low-level design of a key-value store with TTL
- Low-level design of a notification service
- Low-level design of a parking lot
- Low-level design of a rate limiter class
- Low-level design of a task scheduler
- Low-level design of a vending machine
- Low-level design of an elevator system
- Low-level design of an expense-sharing app
- Low-level design of an LRU cache
- Making illegal states unrepresentable
- Measuring coupling between modules
- Modelling a file system with the composite pattern
- Modernising a legacy codebase while shipping features
- Moving from anemic to rich domain model
- Plugin architectures and extension points
- Service locator as an anti-pattern
- Teams keep breaking module boundaries
- The specification pattern
- Trade-offs of dependency injection containers
- Traits and mixins vs inheritance