liveBook · Manning

Backward compatibility

As explained in Practices of the Python Pro

Backward compatibility is the ability of a newer software version to preserve compatibility with earlier interfaces, data, or behavior.

Backward compatibility lets software evolve without breaking interfaces or behavior that existing consumers already rely on. During a refactor, preserve the old entry points while changing the implementation underneath. section 9.3.2

Figure 9.4. Mail can be forwarded by the post office when you move to a new location.

Think of compatibility like mail forwarding: old addresses continue working while calls are redirected to the new implementation. section 9.3.2

Preserve compatibility during a class extraction by:

  • Moving the new responsibility into a separate class. section 9.3.2
  • Keeping the original class interface available. section 9.3.2
  • Forwarding old properties or calls to the new class. section 9.3.2
  • Warning consumers before eventually removing the old interface. section 9.3.2

Extracting author details

After extracting an Author class from Book, retain book.author_for_display and book.author_for_citation as forwarding properties. New code can use book.author.for_display instead, allowing consumers to migrate gradually. section 9.3.2

How Practices of the Python Pro covers it

How deep it goes
Defines the practice, explains forwarding through an analogy, and demonstrates it with Python class properties and deprecation warnings.
Examples
Uses post-office mail forwarding and a Book-to-Author extraction with preserved properties.
What it assumes
Assumes basic software interfaces and Python classes while teaching the compatibility technique from its practical motivation.
What you can do after
Apply it by forwarding old interfaces to extracted classes and warning consumers about preferred replacements.
How it connects
Connects backward compatibility to refactoring, class extraction, forwarding, and deprecation warnings.

Also explained in

Compare how 18 books explain backward compatibility →

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.