Introducing PEAR, the functional SOLID

After reading the article from Edward Guiness with examples on how SOLID is implemented, I've come to want to add some things to SOLID myself, that were learned from my adventures in functional programming.

I'm introducing now:


(P)ure functions
(E)xpect (A)nything (and Address Domain)
(R)eturn early.

(also because acronyms are cool)

(P)ure Functions

As long as you don't have to do things that modify state, or writes to I/O, try to encapsulate them into pure functions. Pure functions are those who don't have a side effect.

When possible, and not constrained by memory use:

(E)xpect (A)nything (and Address Domain)

Let's say you are making a function to sum the digits in an array. One of the main learnings of my trip through clojure was to make your input work, for all the elements in a domain.

Let's assume two things, we don't have python's sum(), and we are creating a function that adds all the elements in a list.

This guarantees that your software isn't going to crash because of an unhandled exception, and allows you to think in different ways.

You can even do this in statically typed languages like C#, for certain types, or using dynamic.

(R)eturn early

But I'll show a simple example.

Over time, i've found in my short coding career, that these save a lot of time figuring out pain points, and helps get to more practical and usable software.

What are your coding principles? The ones you couldn't live without? I'd love to know more principles you like.


“Understanding the SOLID Principles” by Edward Guiness (from the book “Ace the Programming Interview: 160 Questions and Answers for Success” published by Wiley in 2013) Retrieved from: