Skip to Content
面向对象的思考过程(原书第5版)
book

面向对象的思考过程(原书第5版)

by 马特 魏斯费尔德
August 2021
Intermediate to advanced
450 pages
4h 46m
Chinese
Pearson
Content preview from 面向对象的思考过程(原书第5版)

5.4.1 记录类并使用注释

在每个关于编程的书籍和文章、每次代码审查以及每次对优秀设计的讨论中都有关于注释和文档的主题。不幸的是,注释和优秀的文档往往不受重视,甚至更糟的是完全被忽略。

大多数开发人员知道应该始终对代码添加文档描述,但通常并不想花时间这样干。然而,如果没有优秀的文档实践是不可能驱动出优秀的设计的。在类级别,范围可能足够小,开发者可以侥幸远离劣质文档。然而,当类被传递给其他人进行扩展和(或)维护时,它可能会变成一个更大的系统(这种情况很常见),缺失正确的文档和注释会破坏整个系统。

前人已经讲过这些。优秀设计的最重要的方面之一是,设计类时应该小心地记录过程。譬如Java和.NET的实现提供了特殊的注释语法来帮助文档化过程。请看第4章来查看相应的语法。

太多的文档

请注意,注释过多也可能是个问题。太多的文档和(或)注释会成为背景噪声,而且可能会背离文档本来的目的。就像优秀的类设计一样,保持文档和注释简单易懂。编写规范的代码,本身就是最好的注释。

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Node与Express开发(第2版)

Node与Express开发(第2版)

Ethan Brown
手把手教会你linux

手把手教会你linux

桑德.范.乌格特
Java并发编程实战

Java并发编程实战

Brian Goetz, Tim Peierls

Publisher Resources

ISBN: 9787111684527