0

In Germany we use the expression "Clean Code" (loanword) to describe source code that is well written. Lately I came to translate "Clean Code" literally to german and had an idea that in english there could be several meanings:

  1. Clean Code: well written source code
  2. Clean Code: a set of rules (code) to keep everything clean

Yet I am not certain whether the second meaning could be a valid interpretation in english. So maybe a native speaker could give me an answer. If I am wrong with the second interpretation it would be kind to explain why my interpretation is differnt from that of native speakers.

Edit:

I know the contents of the "Clean Code" book and I know the primary meaning of clean code. So please do not explain to me how to code cleanly - it is off topic. I want to know whether the term "clean code" used in a context beyond software engineering code be understood as rules how to keep everything clean.

11
  • 2
    Here, “Code” refers to source code, not rules or laws. Therefore, I'd translate “clean” as „sauber“ in the sense of „ordentlich“ → „sauberer Code“ oder „ordentlicher Quelltext“. If “clean code” referred to rules about keeping clean, it would be a “cleanliness code” (German: Sauberkeits-Ethos, nicht: sauberes Gesetzbuch).
    – amon
    Commented Oct 29, 2017 at 11:40
  • I am quite aware of the intended meaning. My question was whether there is a hidden meaning in "clean code". So a complete answer to my question would be an explanation (!) why nobody would expect "Clean Code" to be a code of rules about writing "clean" source code. From your comment I cannot see whether "cleanliness code" makes the expression unambiguous or whether "clean code" is bad english.
    – CoronA
    Commented Oct 30, 2017 at 5:18
  • Then maybe you'd get a better answer from the English Language SE (or similar)?
    – user214290
    Commented Oct 30, 2017 at 16:15
  • I do not need an academic justification. @Amon: Your profile points to the fact that you are located in Germany. Are you truely a native speaker? Or did you speak with native speakers about this subject?
    – CoronA
    Commented Oct 30, 2017 at 16:33
  • Better developers consider code produced using the "clean code" book guidelines, "ugly code" i.e. the opposite of what was intended. Just to add to your confusion. :) Commented Oct 30, 2017 at 18:50

2 Answers 2

5

Clean Code is a buzzword given to us by Uncle Bob (Robert Martin) in his book of the same name: Clean Code.

As Amon points out code refers to source code. However Uncle Bob published a second book called Clean Coder with the sub title of "A code of conduct for profesional programers". In this case "code" in the subtitle does not refer to source code. However, "coder", refers to someone who writes source code. So it's easy to say it can be either 1 and 2. However, as I read the book Clean Code I translated it as meaning source code most of the time.

Personally I don't think of them as a code of rules the same way I think of building codes. Someday they might be, but right now they are ideals we reach for when a solution could take more than one form.

If what you're looking for is a way to review someone's work to determine if it conforms, we typically use other words for that: standards, conventions, and style guideline.

The books get into stuff far more subjective and difficult to impose on others. They are very good ideals to reach for, ask for, but there's never going to be a tool that will confirm if you chose a good name. For that you need to talk to your team.

In general the term refers to code that meets ideals that have nothing to do with whether the code works. Humans like clean code. Computers don't care.

3
  • 1
    Maximum respect to Mr. Martin, but I'm pretty sure usage of the term "clean code" predates the first printing Clean Coder.
    – John Wu
    Commented Oct 29, 2017 at 17:39
  • 1
    @John: I think we all agree on that. But that was not my point. I wanted to know whether the second meaning is thinkable - or just bad english (i.e. nobody, even children would not expect the second interpretation).
    – CoronA
    Commented Oct 30, 2017 at 5:24
  • I think we need to recognize that "Clean Coder" is meant to be an allusion to the term "Clean Code." In context, it means, "a coder who writes clean code." So meaning #1 is still the prevalent sense of the term even though the book is about rules for writing clean code, IMO.
    – jschmitter
    Commented Nov 2, 2023 at 20:14
1

"Clean code" refers to source code that is "clean." It does not refer to any sort of code as in code of behavior (e.g. code of conduct or legal code). It's source code. So your answer is #1.

In this context, "clean" is not particularly well-defined, but generally means that the code is free from unnecessary complexity, free of code smells, and otherwise free of clutter that would make it difficult to read or maintain. It is understandably subjective. Books have been written about it, such as Martin's Clean Code.

Some engineers use "clean" interchangeably with "good." Also, it comes up in other contexts, e.g. "clean design," which could mean a number of things. Personally I discourage both terms in technical discussions since they lack any agreed or actionable definition.

If you are looking for a term that indicates "a set of rules to keep everything clean," some terms that might apply are coding standards and coding conventions.

For comparison, see also elegant code and SOLID code.

5
  • The question was not "either 1 or 2". I know what clean code is. I just do not know whether a native speaker (without background in software engineering) could misinterpret this term. In Germany this is unthinkable, because code (which is used in german language) has no second meaning in german.
    – CoronA
    Commented Oct 30, 2017 at 16:37
  • No, a typical native speaker would never take "clean code" to mean #2.
    – John Wu
    Commented Oct 30, 2017 at 17:09
  • SOLID has the same problem. "SOLID" has nothing to do with producing solid code, in the English sense of the term. Commented Oct 30, 2017 at 22:13
  • But SOLID is a good example for a term that has two meanings - one as acronym and one as word "solid". And I am quite sure that this is intended.
    – CoronA
    Commented Oct 30, 2017 at 22:31
  • @CoronA Intended, yes, and the source of many problems as the various techniques within are misapplied... Commented Oct 31, 2017 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.