Mixin

Diff with inheritance

  • Normal Inheritance: Represents an "is-a" relationship. For example, a Dog "is a" Animal. The parent class defines the core functionality and attributes that are fundamental to the child class's identity.
  • Mixin Inheritance: Represents a "has-a" or "can-do" relationship. The mixin provides a specific, often standalone, piece of functionality that the class "has" or "can do." For example, a User class "can" be converted to a dictionary (ToDictMixin), or a DataProcessor "has" logging capability (LoggingMixin).
SuperMade with Super