en
Robert Martin

The Robert C. Martin Clean Code Collection (Collection)

Сообщить о появлении
Загрузите файл EPUB или FB2 на Букмейт — и начинайте читать книгу бесплатно. Как загрузить книгу?
  • b4777467766цитирует13 дней назад
    If you decide to write a comment, then spend the time necessary to make sure it is the best comment you can write.
  • b4777467766цитирует13 дней назад
    It takes only a few seconds of thought to explain most of your intent in code. In many cases it’s simply a matter of creating a function that says the same thing as the comment you want to write.
  • b4777467766цитирует13 дней назад
    Rather than spend your time writing the comments that explain the mess you’ve made, spend it cleaning that mess.
  • b4777467766цитирует16 дней назад
    The older a comment is, and the farther away it is from the code it describes, the more likely it is to be just plain wrong. The reason is simple. Programmers can’t realistically maintain them.

    Code changes and evolves. Chunks of it move from here to there. Those chunks bifurcate and reproduce and come together again to form chimeras. Unfortunately the comments don’t always follow them—can’t always follow them. And all too often the comments get separated from the code they describe and become orphaned blurbs of ever-decreasing accuracy.
  • b4777467766цитирует16 дней назад
    Inaccurate comments are far worse than no comments at all. They delude and mislead.
  • b4777467766цитирует16 дней назад
    In the end, I wind up with functions that follow the rules I’ve laid down in this chapter. I don’t write them that way to start. I don’t think anyone could
  • b4777467766цитирует16 дней назад
    So if you keep your functions small, then the occasional multiple return, break, or continue statement does no harm and can sometimes even be more expressive than the single-entry, single-exit rule.
  • b4777467766цитирует16 дней назад
    Classes like this are a dependency magnet; many other classes must import and use them. Thus, when the Error enum changes, all those other classes need to be recompiled and redeployed.1
  • b4777467766цитирует16 дней назад
    Returning error codes from command functions is a subtle violation of command query separation. It promotes commands being used as expressions in the predicates of if statements.

    if (deletePage(page) == E_OK)

    This does not suffer from verb/adjective confusion but does lead to deeply nested structures. When you return an error code, you create the problem that the caller must deal with the error immediately.
  • b4777467766цитирует16 дней назад
    Returning error codes usually implies that there is some class or enum in which all the error codes are defined.
fb2epub
Перетащите файлы сюда, не более 5 за один раз