Procedural vs. Object-Oriented code

--

Procedural code is easy to understand but harder to change. Object-oriented code is harder to understand but easy to change.

A simple procedure is the easiest thing. It’s easy to change and easy to understand. Simple in this context means it’s short and has no conditions.

The problem with simple procedures is they don’t scale.

Simple procedures accumulate conditionals. Over time they become hard to understand and thus change.

Object-Oriented Design uses messages to add levels of indirection.

Object-Oriented Design adds complexity. Yet, indirection makes the solution harder to understand, with the added benefit of changeability.

If a problem can be solved with a simple procedure, you should not be writing OO[¹]

Business change is inevitable. Code arrangement should account for future change while leaving many options open for the team.

— — -

[¹]: Sandi Metz (2019): Polly Want a Message(https://www.youtube.com/watch?v=YtROlyWWhV0)

--

--

Rafael A. George Duval
Rafael A. George Duval

Written by Rafael A. George Duval

✍🏼 Building a Solo Digital Media Company 🧪 Snippets of Text [https://snippetsoftext.substack.com/subscribe]

No responses yet