How do you decide what should be a class versus what should be an attribute when modeling a real-world system?

Last updated 5 July 2026

  • Make it a class if it has its own behavior, rules, identity, or lifecycle, or groups related data that travels together (e.g. Address).

  • Make it an attribute if it is a simple descriptive value (name, count, color) with no meaning apart from its owner.

  • Promote an attribute to a class once it sprouts rules and related data (avoid "primitive obsession").

  • https://www.thoughtworks.com/insights/blog/agile-project-management/domain-modeling-what-you-need-to-know-before-coding
  • https://medium.com/@annxsa/intro-to-oop-classes-objects-properties-methods-27fd259572b4
All Object-Oriented Programming interview questions