Design Principles are prescriptive guidelines on how to design and structure software. They are actionable rules you follow when writing code.

What Makes Something a Design Principle?

A design principle:

  • Prescribes behavior: Tells you HOW to write code
  • Is actionable: You can apply it directly in your work
  • Guides decisions: Helps you choose between alternatives
  • Can be violated: You consciously choose to follow or break it

Examples of prescriptive statements:

  • “Favor composition over inheritance”
  • “Tell objects what to do, don’t ask for their state”
  • “Don’t repeat yourself”

Fundamental Principles

Code Reuse and Abstraction

Object-Oriented Design

Class Design (SOLID)

  • SOLID Principles - The five fundamental principles of object-oriented class design

How Principles Relate to Concepts

Design principles are grounded in design concepts. Understanding the concepts (like invariants, encapsulation, cohesion) helps you understand WHY the principles matter and when to apply them.

Principles vs. Patterns

  • Principles: General guidelines applicable across many situations
  • Patterns: Specific, reusable solutions to common problems

See also: Design Patterns

References

From Good Software Practices