Search code examples
coding-style

Technical term for bad naming coding style


One of my tasks is to analyze source code. The chunks that usually takes the most time to be understood are those where the developer uses confusing terms for variables or methods, like...

  • myfavoritething=json.dumps(url) (what is this variable? what is the purpose? apparently the user is encoding the url for some dark purpose...)
  • public void getName(values, result) { ... (this was not a getter, the function has no return value, but it calculates a result from the input values)
  • POST /loadService (which does not load something, just returns a lot of variables)

Given that this is a quite common issue, is there a technical term for this coding-style bad habit?


Solution

  • Bad naming is considered to be a so called code smell. The term was first coined by Kent Beck.

    In his book Refactoring: Improving the Design of Existing Code, Second Edition Martin Fowler describes patterns that help with refactoring specific flaws in code.

    He also dedicates a chapter to code smells which are closely related to refactoring.

    Getting back to your question:

    Given that this is a quite common issue, is there a technical term for this coding-style bad habit?

    As I consider this book as one of the top sources concerning this topic I would say the term that comes closest to what you are referring to is the Mysterious Name code smell as described in Fowlers book:

    Mysterious Name

    Puzzling over some text to understand what’s going on is a great thing if you’re reading a detective , but not when you’re reading code. We may fantasize about being International Men of Mystery, but our code needs to be mundane and clear. One of the most important parts of clear code is good names, so we put a lot of thought into naming functions, modules, variables, classes, so they clearly communicate what they do and how to use them.

    Finding good names often is hard and if you are looking for some good advice in the right direction I recommend the book Clean Code by Uncle Bob. He dedicates a whole chapter (see Chapter 2 - Meaningful Names) to this topic.