The Object Oriented Way
$29.99
Minimum price
$39.99
Suggested price

The Object Oriented Way

About the Book

Have you ever wondered why there are so many rules in object oriented programming?

I asked myself that question a decade ago. This book is the result of everything I’ve learned since.

I'm Christopher Okhravi (PhD), a Senior Lecturer at Uppsala University and a YouTuber with over 150,000 followers. I’ve spent the last ten years decoding OOP — so you don’t have to.

This is a practical, language-agnostic guide to OOP. It gives you mental models to reason about complexity and choose the right abstraction at the right time.

I use it in my own teaching. Now, it can be yours.

🔒 Buy Now and Unlock Private Community Access

When you buy the book, you’ll get exclusive access to a private community where you can:

  • ✅ Ask questions and get feedback.
  • ✅ Showcase your apps and ideas.
  • ✅ Learn alongside other developers.

🥇 #1 on LeanPub. Top 10 for months.

The feedback has been overwhelming:

  • "I've been coding for almost a decade, and I've never seen these concepts explained this well.”
  • "This is one of the best pieces of advice.”
  • "Wow! Such a clean and logical delivery!"
  • "Finally, I get the concept after using it for so many years without fully understanding it."
  • "No one will forget this now."
  • "I name you the OOP maestro 🥂"

🧠 What You’ll Learn

Inside, you’ll learn how to think about OOP — not just memorize it.

  • When to use subtypes instead of objects.
  • When to choose dependency injection over instantiation.
  • When to use interfaces or composition over inheritance.
  • How strategies, delegates, and higher-order functions solve the same problem.
  • How bridge is like a strategy within a strategy.
  • How dependency injection and replacing conditionals with polymorphism lead to dependency inversion.
  • How observables are like events, observers like delegates, and how they all relate to asynchronous and reactive programming.
  • How iterators and enumerables relate to streams and infinite lists.
  • How the visitor pattern is like pattern matching.
  • How Variance is the key to the Liskov Substitution Principle and what it enables.
  • And more…

🙋‍♂️ Frequently Asked Questions

📘 Is this too advanced for me? No. We start from the very basics. No assumptions, no jargon walls. You don’t even need to know what a class is.

🧠 Is this too simple for me? No. The book scales up. Skip the chapters you find easy. Even seasoned developers find the book enlightening.

📦 Will there be a paperback version? Possibly. If the digital version does well, a paperback could follow. Buying early helps make that happen.

Why buy before it’s complete? Because early buyers get exclusive access to a private community where you can ask questions, share your projects, and learn directly from me and other readers.

🔑 How do I join the private community? Instructions are included in the email you get after purchasing.

📅 When will the final version be done? The book is being released chapter by chapter, and updates are frequent. Your purchase includes all future updates at no cost.

About the Author

Christopher Okhravi
Christopher Okhravi (PhD)

I am a university lecturer (Uppsala University, Sweden) by day and a YouTuber by night.

I have been teaching object oriented programming to university students for over a decade and I hold a PhD in Information Systems (where I used Haskell to model policy interventions for antibiotics development as financial contracts).

On YouTube I am most famous for my deep diving playlist on Object Oriented Design Patterns but am uploading content on anything from functional programming to architecture.

I love abstractions and this is why I love programming.

I write simple books because that's what we all deserve :)

You can reach me at: author@theobjectorientedway.com

Table of Contents

    • Preface
      • How To Read This Book
    Part I:Imperative Programming
    • 1.Programming
      • 1.1.Algorithms
      • 1.2.Computation
      • 1.3.Programs
      • 1.4.Syntax
      • 1.5.Compilation
      • 1.6.Execution
      • 1.7.Interpretation
      • 1.8.Comments
    • 2.Data
      • 2.1.Values
      • 2.2.Variables
      • 2.3.Data Types
      • 2.4.Constants
      • 2.5.Type Checking
      • 2.6.Type Inference
      • 2.7.Null
      • 2.8.Dynamic Types
    • 3.Expressions
      • 3.1.Arithmetic Operators
      • 3.2.Equality Operators
      • 3.3.Relational Operators
      • 3.4.Logical Operators
      • 3.5.String Concatenation
      • 3.6.String Interpolation
      • 3.7.Assignment Operator
      • 3.8.Precedence
      • 3.9.Associativity
    • 4.Control Flow
      • 4.1.Statements
      • 4.2.Selection Statements
      • 4.3.Selection Expressions
      • 4.4.Conditionals Breed
      • 4.5.Iteration Statements
      • 4.6.Exceptions
    • 5.Methods
      • 5.1.Local Functions
      • 5.2.Parameters
      • 5.3.Return Values
      • 5.4.Fat Arrows
      • 5.5.Recursion
    • 6.Type Definitions
      • 6.1.Enumeration Types
      • 6.2.Tuples
      • 6.3.Arrays
      • 6.4.References and Values
    • 7.Organization
      • 7.1.Namespaces
      • 7.2.Entry Point
      • 7.3.Global Variables Considered Harmful
    Part II:Object Oriented Programming
    • 8.Objects
      • 8.1.Classes
      • 8.2.Fields
      • 8.3.Constructors
      • 8.4.Instance Methods
      • 8.5.The this Keyword
      • 8.6.Encapsulation
      • 8.7.Access Modifiers
      • 8.8.Properties
      • 8.9.Static
      • 8.10.Overloading
      • 8.11.Extension Methods
    • 9.Object Composition
      • 9.1.Dependency Instantiation
      • 9.2.Dependency Injection
      • 9.3.Tell Don’t Ask
      • 9.4.Law of Demeter
    • 10.Type Design
      • 10.1.Primitive Obsession
      • 10.2.Make Impossible States Impossible
      • 10.3.Bijection
      • 10.4.Throwing Exceptions
      • 10.5.Fail Fast
    • 11.Subtype Polymorphism
      • 11.1.Substitutability
      • 11.2.Interfaces
      • 11.3.Run-Time Type vs Compile-Time Type
      • 11.4.Dynamic Dispatch
      • 11.5.Replace Conditional With Polymorphism
      • 11.6.Not All Conditionals Can Be Replaced With Polymorphism
      • 11.7.Don’t Use Subtypes for Data Variation
      • 11.8.Multiple Interfaces
      • 11.9.Interface Segregation Principle
    • 12.Inheritance
      • 12.1.Class Inheritance
      • 12.2.Overriding
      • 12.3.Hiding
      • 12.4.The base Keyword
      • 12.5.Constructor Chaining
      • 12.6.Protected Access Modifier
      • 12.7.Abstract Classes
      • 12.8.When To Use Inheritance
      • 12.9.Hierarchical Reuse
      • 12.10.Interface Inheritance
      • 12.11.Default Interface Methods
      • 12.12.Multiple Inheritance
      • 12.13.Fragile Base Class Problem
    • 13.Type Conversions
      • 13.1.Kinds of Type Conversions
      • 13.2.Upcasting
      • 13.3.Downcasting
      • 13.4.Everything Is An Object
    • 14.UML Class Diagrams
      • 14.1.Classes
      • 14.2.Fields
      • 14.3.Access Modifiers
      • 14.4.Properties
      • 14.5.Instance Methods
      • 14.6.Constructors
      • 14.7.Composition
      • 14.8.Interfaces
      • 14.9.Inheritance
      • 14.10.Abstract
    • 15.More Type Definitions
      • 15.1.Structure Types
      • 15.2.Record Types
      • 15.3.Anonymous Types
    Part III:Advanced Object Oriented Programming
    • 16.Generics
      • 16.1.Can Everything Be Generic?
      • 16.2.Generic Types
      • 16.3.Generics Maintain Static Type Safety
      • 16.4.Generic Supertypes
      • 16.5.Generic Methods
      • 16.6.Type Parameter Constraints
      • 16.7.Collections
    • 17.Composition Over Inheritance
      • 17.1.The Duck Dilemma
      • 17.2.Strategy Pattern
      • 17.3.Bridge Pattern
      • 17.4.Delegates
      • 17.5.Generic Delegates
      • 17.6.Multicast Delegates
      • 17.7.Lambdas
    • 18.Dependency Inversion
      • 18.1.Depend on Abstractions, Not on Concretions
      • 18.2.Dependency Inversion Principle
      • 18.3.Factory Method Pattern
    • 19.Observers
      • 19.1.Observer Pattern
      • 19.2.Events
      • 19.3.Event-Driven Programming
      • 19.4.Asynchronous Programming
      • 19.5.Reactive Programming
    • 20.Iterators
      • 20.1.Iterator Pattern
      • 20.2.Enumerables
      • 20.3.The yield Statement
      • 20.4.Lazy Evaluation
      • 20.5.Infinite Iterators
      • 20.6.LINQ
    • 21.Multiple Dynamic Dispatch
      • 21.1.Visitor Pattern
      • 21.2.Pattern Matching
    • 22.Variance
      • 22.1.Type Safe Variance
      • 22.2.Covariance
      • 22.3.Contravariance
      • 22.4.Invariance
      • 22.5.The Square-Rectangle Problem
      • 22.6.Liskov Substitution Principle
      • 22.7.Variant Class Inheritance
      • 22.8.Variant Delegates
      • 22.9.Variant Generic Delegates
      • 22.10.Variant Generic Interfaces
    • Epilogue

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub