Object or Entity should have only one responsibility.

  • The Single Responsibility Principle (SRP) states that a class should have only one reason to change
  • One Class should be responsible for one task.
  • The class itself is a single unit that must either be entirely used or not at all (discounting static methods and data for the moment).
  • If you can think of more than one motivation for changing a class, it probably has more than one responsibility.

Examples of Responsibilities:

  • Persistence
  • Validation
  • Notification
  • Error Handling
  • Logging
  • Class Selection / Instantiation
  • Formatting
  • Parsing
  • Mapping