Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
How to OOP A Primer for Novice Developers
Slide 2
Slide 2 text
Marco Petersen @ocrampete16
Slide 3
Slide 3 text
✗ an advanced OOP talk ✓ an intro to proper OOP
Slide 4
Slide 4 text
Seasoned devs aren’t going to learn anything new.
Slide 5
Slide 5 text
For people who know how classes work but don’t know how to use them effectively.
Slide 6
Slide 6 text
Rich domain model Composition for code reuse Classes that focus on one thing
Slide 7
Slide 7 text
Slides are on Speaker Deck at speakerdeck.com/ocrampete16
Slide 8
Slide 8 text
Use classes to create a rich domain model.
Slide 9
Slide 9 text
Your domain model is what your business is about.
Slide 10
Slide 10 text
Model real-world behavior.
Slide 11
Slide 11 text
Infrastructural concerns are irrelevant.
Slide 12
Slide 12 text
Use classes to create a rich domain model.
Slide 13
Slide 13 text
Composition for code reuse, not inheritance.
Slide 14
Slide 14 text
Inheritance is for specialization, not for sharing logic.
Slide 15
Slide 15 text
Is it a “more specific version” of this thing?
Slide 16
Slide 16 text
Extract what’s different and “inject” it. (Dependency Injection)
Slide 17
Slide 17 text
Dependency Injection !== Dependency Inversion
Slide 18
Slide 18 text
Composition for code reuse, not inheritance.
Slide 19
Slide 19 text
Smaller classes that only do one thing.
Slide 20
Slide 20 text
Single Responsibility Principle (SOLID)
Slide 21
Slide 21 text
What a “responsibility” is depends on the layer of abstraction you’re at.
Slide 22
Slide 22 text
When is a class too big? Uncle Bob: more than one reason to change Uncle Marco: lots of dependencies
Slide 23
Slide 23 text
Smaller classes that only do one thing.
Slide 24
Slide 24 text
FINAL RECAP!
Slide 25
Slide 25 text
Write classes that model the real world.
Slide 26
Slide 26 text
Extract shared logic into their own classes and inject them.
Slide 27
Slide 27 text
Classes should focus on doing one thing well.
Slide 28
Slide 28 text
Thanks! Questions?