How to program without OOP

  1. As mentioned, modules are typically much larger in scale. Unlike in OOP, we are not trying to atomize our code into bite-sized units. It’s a quantitative difference that produces a significant qualitative difference: when our units of encapsulation get too small, our code becomes predominated by interfaces and ceremony rather than actual business. Instead of a large, complex graph of objects, we want a small, simple graph of modules.
  2. Modules may contain data, but they are not themselves data types. Modules also may contain definitions of data types public to other modules. Unlike in OOP, we are not trying to corral a data type and all of its operations into a single unit of encapsulation. The purpose of module encapsulation is to protect state, not necessarily to keep knowledge of data types private.
  1. …do not split large modules into smaller modules out of guilt.
  2. …keep the graph of module relationships acyclical.
  3. …as much as possible, avoid sharing the state of a module amongst multiple other modules. (Or more accurately, avoid sharing the state of a module ‘instance’.)
  1. Don’t atomize units of encapsulation.
  2. Don’t atomize functions/methods.
  3. Don’t conflate units of encapsulation and data types.

--

--

--

Programmer of stuff. Youtuber of programming education videos (http://t.co/87idIfrXBA). Him who eats time.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Brian Will

Brian Will

Programmer of stuff. Youtuber of programming education videos (http://t.co/87idIfrXBA). Him who eats time.

More from Medium

Struggling with programming?: Lessons I Learnt From “How To Think Like a Programmer” (1)

Understand the Recursion

My Journey With Software Development.

3 UNCOMMON MISTAKES WE MAKE AS BEGINNERS WHILE LEARNING HOW TO CODE