Why do people write convoluted code
What's wrong with comments explaining complex code?
The need for comments is inversely proportional to the level of abstraction in the code.
For example, assembly language is incomprehensible for most practical purposes without comments. Here is an excerpt from a small program that calculates and prints Fibonacci series terms:
Groking can be tricky, even with comments.
Modern example: Regexes are often very low abstraction constructs (lowercase letters, numbers 0, 1, 2, new lines, etc.). You will likely need sample comments (Bob Martin, IIRC, recognizes this). Here is a regular expression that (in my opinion) should match HTTP (S) and FTP URLs:
As languages evolve the abstraction hierarchy, the programmer can use evocative abstractions (variable names, function names, class names, module names, interfaces, callbacks, etc.) to provide integrated documentation. Neglecting to take advantage of this and to put comments on paper is lazy, a disservice and disrespect to the supervisor.
I think of Numerical recipes in C , mostly literally in Numeric recipes have been translated into C ++ what I call Numerical recipes (in FORTAN) with all variables, began,,, etc. that are managed in each version. The algorithms may have been correct, but they did not take advantage of the abstractions of the languages provided. And they kill me. Example from an article by Dr. Dobbs - Fast Fourier Transform:
As a special case of abstraction, each language has idioms / canonical code fragments for certain general tasks (deleting a dynamic linked list in C). Regardless of what they look like, they shouldn't be documented. Programmers should learn these idioms as they are unofficially part of the language.
So to take away: Non-idiomatic code made up of simple building blocks that cannot be avoided requires comments. And that's WAAAAY less necessary than it happens.
- What is a promise actually
- Is port forwarding secure or unsecure
- Does a market crash affect mutual funds?
- Is topiramate effective for preventing migraines
- Can teenagers have a heart attack
- How Instagram offers unique marketing opportunities
- Why is American Horror Story so underrated
- May refuse treatment to urgent care
- Why should I get a cast iron
- Yoga Infrared yoga is dangerous
- Can you compare school to prison?
- Can i have 2 FHA loans
- What is turbo tuning
- What is Mac Address Filtering
- Which is better an MD or MS
- Mindfulness and relaxation can hinder motivation
- What is the certificate from the Vietnamese embassy
- What does an alternative practitioner do
- Who is the richest person in Monaco
- What is Costa Rica known for?
- What is EzeeKonnect 1
- How do you deal with a depressed partner
- How do I read Finnegans Wake
- Can Catholics eat food that is offered to Gods?