Skip to content
academia.sh

Course Intermediate

The Model–View–Controller Framework

Published Updated

By the end of this course

Start course

01

Framework Structure

A framework that derives template and file names from convention rather than configuration, routing that turns path patterns into a controller and an action, filters that run before the action and flash messages carried to the next request, and views compiled once and escaped on every render.

  1. 01 Convention over Configuration The measuring axis of the course is how many requests a value stays for. The lesson runs the core, sorts thirteen observations into four stays, and shows that the template name is not written, is derived from names, and stays for this request.
  2. 02 Routing Routing turns a path into a controller, an action and an identifier. The lesson measures that a path parameter becomes an integer, that a path that does not match the pattern is rejected, that the pattern order changes the result, and that the value stays only for this request.
  3. 03 Controllers and Filters The controller is built anew on every request and the filter runs before the action. The lesson measures that the filter list is bound to the class, that the controller instance is bound to the request, and that the flash message is carried only to the next request.
  4. 04 Views and Templates A template is compiled once and local values are escaped on every render. The lesson measures what escaping does, that a missing local value raises an error, that double escaping arises in a partial, and that the compiled template is persistent.

02

The Data Layer

The model layer that maps table rows to objects, migrations that change the schema version by version, relationships between records and validations that stop a record before it is written, chained queries, the per-request query cache and the N+1 query problem.

  1. 01 Object–Relational Mapping Measures the layer that maps a table row to an object and a table to a model; shows that a saved value is read by another client too and where the model of this core reaches its limit.
  2. 02 Migrations Measures migrations, which change the table schema version by version; shows that an added column stays persistent, does not reach old rows, and why migrations are numbered.
  3. 03 Relationships and Validations Measures validations that stop a record before it is written and the one-to-many relationship that links records; shows that a validation error stays only in this request and differs from a notice message.
  4. 04 The Query Interface and the N+1 Problem Measures how many queries go to the database: the query cache stays in this request, the N+1 problem and its fix with eager loading, and the way the cache stores an empty result too.

03

Application Services

Identity carried in the session and per-action authorization checks, background jobs moved out of the request, fragment caching and stale content, testing with isolated applications, and the security protections the framework turns on by default.

  1. 01 Authentication and Authorization Measures how many requests a signed-in user's identity stays for, and why the authorization decision is recomputed on every request.
  2. 02 Background Jobs Measures how many requests the record of a queued job stays for, what happens when the worker drains it, and why the result of the job is not in the same stay.
  3. 03 Caching Measures a fragment being produced once and served to later requests, how it differs from the query cache, and how content becomes stale when the key does not change.
  4. 04 Testing Measures reading a controller's instance variable from outside, the difference between a unit test and a feature test, and the effect on isolation of each test building its own application.
  5. 05 Security Defaults Measures why the anti-forgery token is kept in the session, default escaping in the template and an allow list against mass assignment, and closes the course with a table of the stays of thirteen lessons.

Final exam

The Model–View–Controller Framework — Final Exam

In preparation

This course's question bank is not complete yet. The exam opens here automatically once enough questions are added.

Start typing to search.

↑↓ ↵ Esc navigate · open · close