Some clear examples of bad programming include the below. This is of course only scratching the surface. Many code bases are full of bad programming practices which make the lives of those who maintain or debug such code difficult.
- Bad variable names: Variable names such as i, x or tmp are very unhelpful in indicating what the variable is meant to do
- Spaghetti code: Spaghetti code is very difficult to read because there is no separation of code into sections or functions or classes. It just reads like a mess and the fact that it works seems like a miracle
- Not following the single responsibility principle: When a single function or class is doing too many things, it makes life hard for programmers to read such code or avoid bugs. A function named load_xml_file should only load the XML file. It should not also delete some other file or start something else.
- Relying too much on comments for clarity: Often, code changes are not accompanied by changes to comments. So, bad code accompanied by outdated or wrong comments is often deadly and leads to hours or days of effort wasted in trying to figure out what is going on