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.

CoronA
  • 135

2 Answers2

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.

candied_orange
  • 119,268
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.

John Wu
  • 26,955