liveBook · Manning

Extensibility

As explained in Practices of the Python Pro

The property of a software system that permits new functionality to be added without fundamentally modifying its existing structure.

Extensibility lets you add new behavior with little or no impact on existing behavior. Ideally, you add code rather than rewrite code that already works. section 7.1

Think of a web browser with a plugin system: ad blockers and note-taking extensions add capabilities the browser was not built to predict. Extensibility makes later needs possible without rebuilding the core. section 7.1

Recognize extensible design by how new features enter the system:

  • Add classes, methods, functions, or data that encapsulate the new behavior. section 7.1.1
  • Keep concerns separated and components loosely coupled so features remain isolated. section 7.1
  • Avoid shotgun surgery: a feature that requires scattered edits and new conditionals is difficult to extend and maintain. section 7.1.1
  • Invest in design when software will be reused or updated often; extensive redesign may not justify itself for a rarely used script. section 1.5

Adding a response format

Separate response formatting into functions and select one through a mapping from an Accept header. To support another format, add its formatter and mapping entry instead of changing the main endpoint’s behavior. section 9.2.2

Extending an application

A multitier bookmarking application can add an “Import GitHub stars” feature by placing persistence, business logic, and user-interaction changes in their appropriate areas. Interfaces and the command pattern reduce later extension work. section 7.0 section 11.5.1

Figure 7.1. Adding new behavior to extensible code

Use the figure to compare adding behavior through isolated extension points with changing existing code. section 7.1.1

How Practices of the Python Pro covers it

How deep it goes
Defines the property, contrasts isolated additions with shotgun surgery, and demonstrates function-and-configuration extension.
Examples
Uses browser plugins, Bark feature additions, and response-format functions selected through configuration mappings.
What it assumes
Assumes basic software development and introduces extensibility through simple design choices rather than advanced pattern knowledge.
What you can do after
Build extensible Python features by isolating behavior and adding implementations plus configuration rather than scattered conditionals.
How it connects
Connects extensibility with separation of concerns, loose coupling, interfaces, inversion of control, command pattern, and multitier architecture.

Also explained in

Compare how 7 books explain extensibility →

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.