liveBook · Manning

Concern

As explained in Practices of the Python Pro

A distinct responsibility, requirement, or aspect of behavior that software must address.

A concern is a distinct behavior or piece of knowledge that software must address. Separating code by concern creates manageable pieces, reduces the knowledge you must hold in mind, and makes intent easier to follow. section 2.0

Separate concerns at several levels, choosing boundaries that reflect distinct activities:

  • Functions can isolate focused behaviors such as choosing input, printing options, or determining a result. section 2.2.1
  • Classes, modules, and packages can establish larger boundaries when responsibilities or knowledge begin to mix. section 2.0 section 9.3

Generalizing a group introduction

A fan-page function that knows both the Three Stooges title and how to introduce names mixes concerns. Extracting the title as an argument supports other groups, while join_names() separately handles name formatting. section 2.2.1

How Practices of the Python Pro covers it

How deep it goes
Defines concerns, demonstrates function extraction, and applies decomposition to classes, stopping short of low-level implementation theory.
Examples
Demonstrates fan-page introductions, name formatting, and rock-paper-scissors code before and after function extraction.
What it assumes
Assumes Python setup and introduces separation choices progressively through short examples and a real application.
What you can do after
Apply it via Python functions, classes, modules, and packages to separate distinct behaviors and knowledge.
How it connects
Connects concerns with separation of concerns, functions, classes, modules, packages, encapsulation, coupling, and decomposition.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Practices of the Python Pro. The section links point to the parts of the book it draws on.