Bimodal programming — why design patterns fail

Also a few solid paragraphs of me explaining why SOLID is bad

A detour into large projects and coding guidelines

The three large open source projects that pop into my mind are pytorch, llvm and clickhouse.

  • Keep “Internal” Headers Private
  • Don’t use else after a return
  • Don’t use default labels in fully covered switches over enumerations
  • Use range-based for loops wherever possible
  • Do not use RTTI or Exceptions
  • When you can chose between X,Y,Z chose Z provided there’s not a really compelling reason to use X and Y.
  • Using A is not forbidden but be careful, because when using A because you’ll likely f*** up.
  • You’ll likely find yourself using boilerplate X a lot, here’s why it’s still a boilerplate and not a function and here’s how to properly go about writing it.
  • We have abstractions X,Y,Z… they are very useful, read what they do carefully and consider using them when they might fit.
  • This is how we test stuff, testing is important and you should do it this way too unless you have a reason not to.
  • This is how we review stuff, keep this in mind when you submit stuff to be reviewed or when you yourself review changes.
  • These are the end goals of our product, code with them always in your mind.

Why design patterns don’t work — Or why SOLID doesn’t respect SOLID principles

Let’s think about the reason why design patterns usually don’t work. We can do that and go backwards from there.

  • One to make code flexible
  • One to make code maintainable

KISS (aka Occam’s razor)

I really do think that’s the problem with most design patterns, they try to accomplish too much. They forget the basic rule of “Keep it simple stupid/silly”, the first and only true design pattern in all of programmings, mathematics and science (also known as Occam’s razor).

Bimodal programming

Allow me to define two concepts for coding, two modes if I may express myself in fancy words that miss-reference poorly-named statistics concepts they are unrelated to: Explore mode and Integrate mode.

In conclusion

Maybe I’m biased towards disliking design principles. I certainly don’t think this is a definitive takedown of the concept, it’s more of a view that tries to explain why the concept might be bad, since design principles are one of those things that always “sound good” but I never actually see them working well in practice.

--

--

You can find my more recent thoughts at https://www.epistem.ink | I cross-post some of the articles to medium.

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
George Hosu

You can find my more recent thoughts at https://www.epistem.ink | I cross-post some of the articles to medium.