liveBook · Manning

Separation of concerns

As explained in A Pythonic Adventure: From Python basics to a working web app

Separation of concerns is a software design principle that divides a system into components with distinct responsibilities.

Give each part of an application one clear job. A data function retrieves orders; a display function and template show whatever data they receive. Change the data request without rewriting the display. section 12.0

The order list

Emily’s order page calls get_orders(), which reads rows from the database. list() passes those rows to list.html, whose loop displays each name, drink, flavor, and topping. Filtering orders changes get_orders(), while the template can keep displaying the returned list.

How A Pythonic Adventure: From Python basics to a working web app covers it

How deep it goes
Demonstrates the principle through database retrieval, route handling, and a template loop without exploring broader design theory.
Examples
Uses an order database, get_orders(), list(), and list.html to display customer orders.
What it assumes
Assumes basic functions, database queries, web routes, and templates while teaching their responsibility boundaries through an order list.
What you can do after
Apply it by changing order retrieval without changing the template that displays returned orders.
How it connects
Connects frontend and backend through data-access functions, routes, databases, and templates.

Also explained in

Compare how 22 books explain separation of concerns →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of A Pythonic Adventure: From Python basics to a working web app. The section links point to the parts of the book it draws on.