Chapter 20: Object-Oriented Programming

Object-Oriented Programming (OOP) is often associated with class-based design, where objects encapsulate both data and methods, and inheritance expresses relationships between types. While OOP can be effective for many problems, Rust emphasizes flexibility via composition, traits, generics, and modules, rather than classical class hierarchies. It supports certain OOP features—like methods, controlled visibility, and polymorphism—but forgoes traditional inheritance as its main design paradigm.