Questions
14 of 24
1What are the SOLID principles? Explain each briefly.
2Explain the Single Responsibility Principle (SRP) with an example.
3Explain the Open/Closed Principle (OCP). How do you achieve it without modifying existing code?
4Explain the Liskov Substitution Principle (LSP). What happens if it's violated? (Square/Rectangle problem)
5Explain the Interface Segregation Principle (ISP). Why are fat interfaces bad?
6Explain the Dependency Inversion Principle (DIP). How does it relate to Dependency Injection?
7What is the difference between Aggregation and Composition?
8What is the Factory Pattern? How does it help in achieving OCP?
9What is the Abstract Factory Pattern? How does it differ from Factory Method?
10What is the Strategy Pattern? How does it replace complex conditional logic?
11What is the Observer Pattern? Where is it used in real life? (Event handling, Pub/Sub)
12What is the Decorator Pattern? How does it add functionality dynamically?
13What is a Singleton Pattern? What are the thread-safety concerns and how to handle them?
14What is an Anti-Pattern? Can you name a few? (God Object, Spaghetti Code, Golden Hammer)
15What is "Coupling" and "Cohesion"? Explain the relationship between them.
16What are Generics/Templates? How do they improve type safety and performance compared to casting?
17What is Type Erasure (Java) vs Reified Generics (C#)?
18What is Variance in Generics? (Covariance and Contravariance)
19What are Extension Methods (C#) or Default Methods (Java)? When should you use them?
20What is Reflection? How can it be used to break Encapsulation? What are the performance costs?
21What is the "Law of Demeter"? (Don't talk to strangers)
22Explain "Tell, Don't Ask" principle.
23What is the DRY principle? How does OOP help achieve it?
24What is the YAGNI principle?
14 / 24

What is an Anti-Pattern? Can you name a few? (God Object, Spaghetti Code, Golden Hammer)

Difficulty: 5/10
anti-pattern identification, code maintainability, design tradeoffs

Anti-Patterns

An anti-pattern is a commonly recurring solution or practice that appears useful initially but tends to create significant problems when applied inappropriately. Anti-patterns are not simply 'bad code'; they are recognizable patterns of poor design or implementation that repeatedly lead to maintainability, reliability or scalability problems.

javascript
  1. 1

    God Object: one class knows or does far too much.

  2. 2

    Spaghetti Code: tangled control flow and dependencies make behavior difficult to understand.

  3. 3

    Golden Hammer: using one familiar technology or pattern for every problem.

  4. 4

    Big Ball of Mud: architecture becomes highly coupled and difficult to reason about.

  5. 5

    Premature Optimization: optimizing before identifying a meaningful performance bottleneck.

  6. 6

    The correct response is to identify the underlying design problem rather than mechanically applying another pattern.

Scenario Questions

0-2 years experience

  1. 1You inherit a small module that has a single class handling UI rendering, data fetching, and logging. How would you refactor it to avoid a God Object?
  2. 2While writing a new feature, you notice the code has long, tangled conditional branches across many methods. What steps would you take to prevent spaghetti code in this context?

2-5 years experience

  1. 1During a code review, a teammate suggests using the same third‑party library for every new problem, even when it's not a good fit. How would you explain the risks of the Golden Hammer anti‑pattern to them?
  2. 2A recent bug was traced to a class that grew to 1500 lines and accessed many unrelated services. Walk me through how you'd diagnose and break down that God Object.

5-8 years experience

  1. 1Our microservice team is experiencing performance degradation because several services share a massive utility class that knows about many domains. How would you redesign to eliminate the God Object at scale?
  2. 2Legacy codebase has spaghetti code that makes automated testing impossible. What strategy would you use to incrementally refactor it while keeping the system stable?

8+ years experience

  1. 1We are planning a migration of a monolithic system that contains many Golden Hammer anti‑patterns, where a single framework is used for all processing pipelines. How would you approach the architectural redesign to avoid lock‑in and improve future extensibility?
  2. 2Across multiple product teams, a shared core library has become a God Object, accumulating responsibilities from different domains. What governance and design practices would you put in place to prevent this and to refactor existing code?

Follow-up Questions

  • Can you walk me through a time you actually refactored a God Object?
  • What metrics would you use to know the refactor succeeded?
  • How would you convince stakeholders to invest in fixing a Golden Hammer situation?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.