Save 37% off PRO during our Black Friday Sale! »

How to OOP: A Primer for Novice Developers

How to OOP: A Primer for Novice Developers

This talk is targeted at beginners that have the basics down but are unsure how to approach object-oriented programming. I'll be presenting 3 key ideas that they can go ahead and apply to their code immediately. Obviously I won't be able to cover everything I'd like to cover, but my hope is that they'll get a solid footing that they can build on.

3dd28ad260d202a12c2e93fc28fad5d7?s=128

Marco Petersen

May 08, 2018
Tweet

Transcript

  1. How to OOP A Primer for Novice Developers

  2. Marco Petersen @ocrampete16

  3. ✗ an advanced OOP talk ✓ an intro to proper

    OOP
  4. Seasoned devs aren’t going to learn anything new.

  5. For people who know how classes work but don’t know

    how to use them effectively.
  6. Rich domain model Composition for code reuse Classes that focus

    on one thing
  7. Slides are on Speaker Deck at speakerdeck.com/ocrampete16

  8. Use classes to create a rich domain model.

  9. Your domain model is what your business is about.

  10. Model real-world behavior.

  11. Infrastructural concerns are irrelevant.

  12. Use classes to create a rich domain model.

  13. Composition for code reuse, not inheritance.

  14. Inheritance is for specialization, not for sharing logic.

  15. Is it a “more specific version” of this thing?

  16. Extract what’s different and “inject” it. (Dependency Injection)

  17. Dependency Injection !== Dependency Inversion

  18. Composition for code reuse, not inheritance.

  19. Smaller classes that only do one thing.

  20. Single Responsibility Principle (SOLID)

  21. What a “responsibility” is depends on the layer of abstraction

    you’re at.
  22. When is a class too big? Uncle Bob: more than

    one reason to change Uncle Marco: lots of dependencies
  23. Smaller classes that only do one thing.

  24. FINAL RECAP!

  25. Write classes that model the real world.

  26. Extract shared logic into their own classes and inject them.

  27. Classes should focus on doing one thing well.

  28. Thanks! Questions?