Jon Wong
Jon Wong
Aug 23, 2017 · 1 min read

This article is too diffuse. It’s an article I would write as a whine to a team I built wrong, trying to convince everyone to fully comprehend and internalize DRY. I feel her agony; I’ve been there, done that worse. In short, any function (small or big) that duplicates idiomatic programming constructs violates the DRY principle.

A key term she uses is “Programming Idioms” (section “Name of the Game”), which mean “native constructs in the programming language”. Take for example this idiomatic construct: for-loop that takes in 4 arguments:

  • Counter variables, and their initial values.
  • Terminating condition.
  • End-of-loop variables update logic. (increments, decrements, etc)
  • For-loop’s body’s logic.

It is certainly possible to create a very small function (or abstraction) that takes in 4 arguments (the 4th may have to be a callback or a lambda) to “abstract” away the principle of a for-loop. What outcome does that serve? Perhaps it helps a programmer to never need to look at the for-loop syntax for that particular programming language? In such a case, we would have duplicated an idiomatic construct in the programming language, violating DRY.

Small functions aren’t the problem. Lack of familiarity with a programming language’s (or library’s) available tools is, in the context of her argument.

)
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade