Hacker News new | ask | show | jobs
by satyanash 1333 days ago
> I'm essentially a believer in You Aren't Gonna Need It — the principle that you should add features to your software — including generality and abstraction

YAGNI is not a principle. It is a contextual thumb rule. A codification of expert intuition. Exceptions to thumb rules are quite the norm. Conflating thumb rules with principles is a sign of sloppy thinking. Often engineers will misuse terminology thinking that it "doesn't matter". But it does. Think twice before claiming that something is a principle. The words you use highly influence your thought process[0].

[0]: https://en.wikipedia.org/wiki/Linguistic_relativity

7 comments

> Conflating thumb rules with principles is a sign of sloppy thinking

Multiple dictionaries and thesauruses would disagree with you there. Rule of thumb is often defined in terms of "rules, procedures, principles, or... ...derived from..."

Some sources say that "rule of thumb is a principle or procedure...""

So, you know, going straight to "sloppy thinking" reminds me of OldManYellsAtCloud.jpg.

Anyway, I'm really not sure what difference you perceive - principles are often derived from experience, as well as theory, and they often have exceptions too.

Many people have a principle of not committing violence, for example. _Except_ when (multiple clauses follow).

That they include "rules" and "procedures" indicates those definitions are based around the "what" rather than the "why". A rule of thumb is something passed down, while a principle is something you come to from experience. A rule of thumb likely started as a principle from someone else.

Rules and procedures are a further watering down of the original idea, where even the rule-of-thumb's justification isn't paid attention to or even has been lost over time.

Your definitions are very interesting there mate. In some contexts, yep, what's often called a rule of thumb (for example, sparkies use a multitude of <X>-hand rules[0][1] and call them rule of thumb, because you know, there's a thumb involved) are passed down.

But people are entirely able to derive their own rules of thumbs, if we hark to the common definition that a rule of thumb is a principle/procedure/process derived from practical experience.

For example, I rapidly developed a rule of thumb when dating post-divorce that any person who said "I hate drama" in their dating profile is in actual fact the source of any drama, but it took me a couple of disastrous dating attempts to develop that rule of thumb.

[0]: https://en.wikipedia.org/wiki/Right-hand_rule#Electromagneti...

[1]: https://en.wikipedia.org/wiki/Fleming%27s_left-hand_rule_for...

Pragmatism vs Dogmatism. For example DRY vs YAGNI. The first is more dogmatic: refactor everything that can be refactored, while the second is more pragmatic. The refactor is probably not necessary and might turn out not to be necessary. An even more pragmatic rule is the You Aint Gonna Need It Yet.
> Pragmatism vs Dogmatism. For example DRY vs YAGNI.

DRY often has exceptions to the "rule"/"principle" too though. And people often blog on these exceptions.

And pragmatism and dogmatism aren't a xor, they're just convenient labels for the -X and the +X ends of the axis.

(Admittedly, the fact that I've seen more "It's okay to have exceptions to DRY" blog posts than "It's okay to have exceptions to YAGNI" indicates you're right about their relative weighting on that axis.)

That is because DRY sets a puzzle for us, how to cleanly reuse some code. YAGNI on the other hand, denies us a puzzle. We like puzzles.
I like your thinking on this
Your semantical argument of "principle" vs "contextual rule of thumb" is incorrect. They mean the same thing in almost every context, according to any dictionary/thesaurus you find out there.

In fact, the ultimate defining characteristic of a "principle" is that it has exceptions and should not be used as the "ultimate word of God".

Even in Physics, where most would think a "principle" means something "without exception", they are only ever currently without exception according to current evidence. There has been countless times where there has been a scientific principle only to be disproven later on.

Lastly, you link Sapir–Whorf, which, quite ironically, is considered a "principle" yet has had much criticism over time, which contradicts your own argument.

However, I will agree with you that one should always be careful of the language they use since it can affect how others view your thoughts, feelings, and intentions.

> The words you use highly influence your thought process

Given that the article is literally about exceptions to YAGNI, and explicitly calls out that there are probably more, their use of the term "principle" doesn't appear to have caused them any harm.

You say

> The words you use highly influence your thought process[0].

Yet in the very article you link it says (emphasis mine)

> The strong version, or linguistic determinism, says that language determines thought and that linguistic categories limit and determine cognitive categories. This version is generally agreed to be false by modern linguists.[3] > The weak version says that linguistic categories and usage only influence thought and decisions.[4] Research on weaker forms has produced positive empirical evidence for a relationship.[3]

Your use of 'highly' would suggest a strong relativity, but that's discredited. Signed, a disgruntled linguist who's tired of people banging on about Sapir-Whorf.

So what would be an example of a software design principle?
Never write a function called destroyBaghdad(). Instead name it destroyCity and pass the target as a parameter.
If Baghdad is city your users destroy most often, I would allow a destroyBaghdad() function that calls destroyCity() with all parameters set correctly.
This is why the US destroyed Baghdad.

The contract is called CongressAuthorizesInvadingCountry(country :Country): Invasion

Congress made a thunk with Iraq in it, so despite the lack of any real connection to Recent Events, the White House called it in 2003.

Ugh.

Try writing destroyKiev instead and see what happens.

Last time I tried, I got a 404 Competent Military Not Found error. :/
My point was that neither routune should ever be written and the Middle East would've been much better off if the world had started an all-out economic war against the US in 2003.

In case you are wondering, I'm Russian, have friends in the Ukraine and destroyed Kiev is the last thing I want.

Jokes about destroying Baghdad are just callous. Especially coming from Americans.

Good thing I'm not American then.

(And the joke I'm referencing is making fun of software ethics, so you're in violent agreement.)

> This can apply to protocols, APIs, file formats etc. It is good to think about how, for example, a client/server system will detect and respond to different versions ahead of time (i.e. even when there is only one version),

A blogpost/article about YAGNI manages to suggest a rather nuanced feature should always be included, that isn't needed, right up front.

Indeed. A rule of thumb is something you're supposed to use, at most, in the absence of any better information. I've written abstractions that didn't end up needed, sure. I've also written abstractions that I've been extremely glad for in hindsight.