Design Patterns interview question · Most asked

What is MVC, and which design patterns does it combine?

Summary

Model-View-Controller separates data and business rules (model), presentation (view) and input handling (controller). Classic MVC combines Observer (views observe the model), Strategy (the controller is the view's strategy for handling input) and Composite (nested views).

Longer Answer

Web frameworks (Rails, Laravel, Django's MTV, Spring MVC, ASP.NET MVC) adapt it: a controller handles an HTTP request, works with models, and renders a view or JSON. Variants include MVP and MVVM (data binding in Vue, Angular, WPF).

The common pitfall is fat controllers; move business logic into models or services.

Key Points

  • Model, view, controller separation.
  • Built from Observer, Strategy and Composite.
  • Web MVC is a request-based adaptation.
  • Avoid fat controllers.

Explanation

What interviewers look for

Responsibilities of each part and awareness of the underlying patterns.

More most-asked Design Patterns questions

← All Design Patterns questions