A
A
Arbil2020-01-28 23:13:04
Programming
Arbil, 2020-01-28 23:13:04

Comments in code?

Hello everyone

I was reading the book "Clean Code" by Robert Martin
And in this book the book says that if the code needs comments, then it is not very good code (Of course this is not a verbatim quote, I was just trying to get the point across)

And at the moment I am reading the book " Perfect Code" by Steve McConnell
And in this book, the author argues that the format of comments is just as important as the names of variables, functions, classes, etc.

Since I'm a beginner self-taught programmer and have very little experience, I don't know who to trust. Is it true that if comments are needed on the code, then it is not of very high quality, or should comments be made on the code?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivan Shumov, 2020-01-28
@Arbil

Let's stop confusing comments in code and documentation. If the first is intended to explain how it works in general, then the second aims to describe the interaction interface, brief descriptions with usage examples and other things that allow, for example, to automatically generate documentation

S
SOTVM, 2020-01-29
@sotvm

Don't teach me how to program.
Comments are not redundant.
5e30e1be57646442252796.gif

// Когда я начинал это писать, только Бог и я понимали, что я делаю
// Сейчас остался только Бог

// иногда мне кажется, что компилятор игнорирует все мои комментарии

// пьян, исправить позже
// Магия. Не трогать.
/**
 * Всегда возвращает true.
 */
public boolean isAvailable() {
    return false;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question