singularity

Chapter 17: Object-Oriented Programming Features

Characteristics of Object-Oriented Languages

Objects Contain Data and Behavior

Encapsulation That Hides Implementation Details

Inheritance as a Type System and as Code Sharing

Using Trait Objects That Allow for Values of Different Types

Defining a Trait for Common Behavior

Implementing the Trait

Trait Objects Perform Dynamic Dispatch

Implementing an Object-Oriented Design Pattern

Defining Post and Creating a New Instance in the Draft State

Storing the Text of the Post Content

Ensuring the Content of a Draft Post Is Empty

Requesting a Review Changes the Post’s State

Adding approve to Change the Behavior of content

Trade-offs of the State Pattern