The Clean Code Blog

by Robert C. Martin (Uncle Bob)

The Force of Pliers

01 November 2015

I was sitting on the throne this morning, my iPhone in my hand, idly perusing the stream of random blather that is Facebook; when my eyes landed upon this post by Kevlin Henney.

As I followed his link, and then the next, and the next, I began to realize the dreadful truth; the horrible situation we are all in. The blood drained from my face. My body shook. The iPhone nearly fell into – nevermind.

The implications of this are no less than galactolyptic.

In the statement 5 X 3 we don’t know which number is the multiplier and which is the multiplicand!

Holy Mathematical Syntax Batman! I thought this was solved years ago. When I was in third grade my teacher, Mrs. Moe, told me that the first number was the multiplicand and the second was the multiplier. That 5 X 3 meant 5 + 5 + 5 and not 3 + 3 + 3 + 3 + 3. In the following 54 years, I have not had any reason to doubt that fact. Indeed, I have written many computer programs that used that labeling.

int multiply(int multiplicand, int multiplier)

Kevlin argues that there is no order since both 5 and 3 are simply factors. But that flies in the face of history! I mean, the words multiplier and multiplicand were chosen for a reason! After all, look at the other operators:

  • 1 + 2: 1 and 2 are both addends.
  • 1 / 2: 1 is the dividend and 2 is the divisor.
  • 1 - 2: 1 is the minuend and 2 is the subtrahend

Notice how those wise men communicated the commutativity of addition by giving both operands the same name! But they did not do that for multiplication because they understood that the two operands of multiplication are not interchangeable, and should be distinguished from one another.

However, not one to rely on past third grade teachers, or Kevlin Henney, for matters of such galactic import, I began to do some research. I found authoritative source after authoritative source, Britannica, Merriam Webster, Wikipedia, Dictionary.com, Ask.com, Wolfram Alpha, The Onion, you name it! Each source confidently declared, asserted, demanded, and bloviated about which operand was the multiplier and which was the multiplicand. But they all said something different!

Great heavens above, The Internet did not agree!

In fact I found three completely contradictory rules.

  1. The first number is the multiplicand.
  2. The second number is the multiplicand.
  3. The larger of the two is the multiplicand.

(That last rule is likely written by some old PDP-8 programmer.)

This is hair raising. Which is it? No one seems to agree!

But perhaps we can apply logic. Perhaps, by the force of sheer reason and intellect, we can work out the proper ordering of these two parameters. If not; then we must henceforth eliminate the two terms and simply call the parameters of multiplication factors.

Oh what a dry and colorless place this world would be without the joyful melody, the childlike impudence, of “multiplier” and “multiplicand”.

So let us examine this statement in intense detail:

5 X 3

If we say this in English we get:

Five times three.

Aha! Now we see the problem. The associativity is ambiguous. This might mean:

five (times three)

or it might mean:

(five times) three.

And as we all know, English verbs need not be associative. Right? I mean (I dug) a hole parses differently than I (dug a hole).

I guess the real question is this. In the sentence: Five times three which is the subject and which is the predicate?

Now, unless you are Yoda, subjects come first. So we should parse this as “(Five times) three” Right? I mean the subject applies the verb to the direct object.

To make this clearer, try saying it the way Yoda would say it. First say “I go to the store” the way Yoda would. Feel the rhythm of it. “To the store I go.” Note the odd inflection on the word “store”. In yodese, that inflection is the denotation marker of the direct object. The nature of that inflection is three tones emitted in rapid succession while vocalizing the vowel. “To the sto-o-ore, I go.” The three tones are connected in an arch that starts at the frequency of ‘the’ then rises a full note, and then descends a half note.

Say it over and over. “Sto-o-ore”. The intonation is almost like you were in the middle of asking a question, but then realized the answer and finished with a conclusion.

OK, now, try that with five times three. You should get Thre-e-e, five times. Can you hear the difference?

So five must be the multiplier! My third grade teacher was wrong. Yoda be praised! We know the answer!



But wait. Something just occurred to me. The word “times” is not a verb.

OH! MY! GOD!

The word “times” is not a verb. It’s a preposition – a goddam preposition! The bane of all English students. The enigma of the English Language. The most ambiguous of all the parts of speech. The part of speech that almost all students are confused by, and go to detention for.

The word itself is an oxymoron. A pre position. A position before any other positions. What kind of nonsense is that? If we took that literally, all prepositions would come before the Big Bang; and we know that nothing came before the Big Bang, because that’s when time started; or at least became non-imaginary…

Anyway, the sentence: “Fives times three.” is not a sentence at all; it’s a – I’m not sure I can say it – prepositional phrase!

And here’s the thing about prepositions… They aren’t transitive. They don’t convey action. They don’t separate a subject from a predicate. They are (gasp) order independent… I mean, FTW (for the win) can be completely inverted!

OK, deep breath. Is there a way that we can convert 5 x 3 into an English sentence, without the preposition? Can we create a true sentence with a subject and a predicate, where the predicate has a verb and a direct object? Let’s try this:

Five is multiplied by 3.

Now that is a sentence. “Five” is the subject. “is Multiplied by three” is the predicate. And in that predicate, “is Multiplied by” is the verb phrase, and “three” is the direct object.

Oh, Hallelujah, we have a sentence. A parseable, meaningful, unambiguous sentence.

And it even works when Yoda says it: “By thre-e-e is five multiplied”.

In fact when Yoda says it, the meaning is even clearer. Five is the number being multiplied. Three is the number by which five is multiplied. It is the multiplication of five, and the number of multiplications is three.

When multiplying five by three, three shalt be the number of thy multiplying, and the number of they multiplying shalt be three. Thou shalt multiply the number five, and five shalt be the number that thouest multiply – and fill the Earth. Eayesudominay!

Therefore, Five is the multiplicand and three is the multiplier. Mrs. Moe was right after all!

Hurray for third grade teachers!