Object (dis)orientation

How to survive a "post-OO" world
Class/Inheritance has challenges
Combining Data + Code

		class MyBase {
			protected:
				int useless;
			public:
				virtual void makeSound() = 0;

				virtual int get_thing() {
					return -1;
				};
		};
		

You have to know if this is an "interface", abstract class, or regular class.

(it's an abstract class, since makeSound is pure virtual)

A class can be one of many things

These concepts all exist under the class keyword
In Rust, you trade Inheritance for Traits and Types.

Traits are Interfaces


	pub trait Mammal {
		fn get_temp(&self) -> i32;
	}
	

... that are explicitly implemented


		pub struct Cat {
			age: i32,
			outdoor: bool,
		}
		impl Mammal for Cat {
			fn get_temp(&self) -> i32 {
				if self.outdoor {
					65
				} else {
					72
				}
			}
		}
		

And can be used statically or dynamically!


		fn static_mammal<T: Mammal>(m: T) {
			// the type of T must be known at compile time.
		}
		fn dyn_mammal(m: &dyn Mammal) {
			// This uses a vtable to dispatch at runtime.
		}