liveBook · Manning

Principle

As explained in Software Design for Python Programmers

A design principle is a general guideline for structuring software to improve qualities such as flexibility, correctness, and performance.

A design principle is a general guideline for structuring software so it becomes more reliable, flexible, maintainable, testable, and responsive to requirements. It improves a function, class, or cooperating set of classes rather than prescribing a complete architecture. section 1.0 section 1.1

Use design principles to:

  • Reduce change leaks by allowing one part of the code to change without forcing unrelated parts to change. section 1.7
  • Control complexity while balancing flexibility against the risk of overengineering. section 1.7
  • Support loose coupling and implementation hiding so classes depend on fewer accessible details. section 5.0
  • Provide the foundation for design patterns, which address recurring software architecture problems at a higher level. section 1.1
  • Guide iterative development, including backtracking when an earlier design decision proves unsuitable. section 2.0

Before-and-after design improvement

Start with a working program whose requirements or hardcoded behavior make later changes difficult. Examine which changes spread across functions or classes, then refactor incrementally to isolate volatile implementation details, reduce dependencies, and improve flexibility. Compare the before and after versions to justify each principle rather than applying a rule mechanically. section 1.2 section 1.7

The main design targets are change and complexity. Good design begins with gathering and analyzing requirements, evolves through multiple iterations, and relies on object-oriented concepts such as abstraction, encapsulation, inheritance, and polymorphism. Encapsulation also isolates parts likely to change. section 1.10 section 2.0

How Software Design for Python Programmers covers it

How deep it goes
Develops principles through before-and-after examples, iteration, implementation hiding, and tradeoffs, without prescribing one complete architecture.
Examples
Uses basic-feature Python programs, before-and-after comparisons, requirement changes, and iterative refactoring with backtracking.
What it assumes
Assumes basic data structures, algorithms, Python programming, and object-oriented programming, while reinforcing core object-oriented concepts.
What you can do after
Evaluate and improve code by isolating change, reducing dependencies, managing complexity, and selecting supporting design patterns.
How it connects
Connects design patterns, loose coupling, encapsulation, abstraction, inheritance, polymorphism, and iterative development.

Also explained in

Compare how 4 books explain principle →

Related concepts

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