Log

#53 | 2025-08-22 06:22:29 UTC
0 replies

MVC (Model-View-Controller) is a pattern in software design for building user interfaces. Key benefit: It keeps code modular - models don't deal with presentation, and views don't contain business rules. 1. The model defines what data the app should contain. 2. The view defines how the app's data should be displayed. 3. The controller contains logic that updates the model and/or view in response to input from the users of the app. Scenario: A user writes a new post on an online forum. - Model: Receives and validates the post data. Handles saving to and loading from the database. - View: Builds the page shown to the user. Either the "New Post" form with validation errors, or the "Post Details" page showing the freshly created post. - Controller: Handles the "create post" request. Flow: - User makes post - Controller receives post data - Model saves to database - Controller chooses a View - User sees result