This document discusses principles of object-oriented programming maintainability such as reuse of behavior, typing and subtyping, and avoiding repetition. It covers different OOP concepts like classes, inheritance, interfaces, mixins and modules. The document suggests using traits for composing units of behavior in a way that is composable and avoids conflicts. Traits should define smaller interfaces than classes. Specifications can also be composed using shared examples. These principles can be achieved in languages like Java 8+, Ruby and Go.
2. Definitions
• Type - Set of methods
• Subtype(T) - Superset methods of the type T
• Class - Implementation of type + properties of
implementing object
46. Using Traits
• Structural classes - Enforce structural integrity.
• Identify interactions - Create smallest possible
interface
• Traits should be smaller or equal to interfaces
• If required - extend structural class to create
glue class for required interface
• Compose using traits