C++ Primer(第5版)- Chapter 7. Classes -004

Note

C++ programmers tend to speak of users interchangeably as users of the application or users of a class.

C++程序员们倾向于将用户(可交换地interchangeably)称为应用程序的用户或者类的用户的一个。

In simple applications, the user of a class and the designer of the class might be one and the same person. Even in such cases, it is useful to keep the roles distinct. When we design the interface of a class, we should think about how easy it will be to use the class. When we use the class, we shouldn't think about how the class works.

在一些简单的应用程序中,类的用户和类的设计者常常是同一个人。即使在这种情况下,把角色区分开来是有好处的。当我们设计一个类的接口时,我们应当考虑怎样才能使这个类易于使用。当我们使用这个类时,我们不应该考虑这个类是如何工作的(我们不应该顾及这个类的实现机理)。

Authors of successful applications do a good job of understanding and implementing the needs of the application's users. Similarly, good class designers pay close attention to the needs of the programmers who will use the class. A well-designed class has an interface that is intuitive and easy to use and has an implementation that is efficient enough for its intended use.

要想开发一款成功的应用程序,其作者必须出色地(充分地)理解并实现用户的需求。同理,优秀的类设计者也会密切关注那些可能使用此类的程序员的需求。一个设计良好的类,既要有直观且易于使用的接口,也必须具备高效的实现过程。

相关推荐
程序喵大人35 分钟前
【C++进阶】STL容器与迭代器 - 01 STL 容器先解决元素放在哪里
开发语言·c++·stl
cui_ruicheng1 小时前
Python从入门到实战(十六):多进程编程
开发语言·python
Jelena157795857922 小时前
电商运营分析数据比价接口实战:多平台价格监控与智能决策系统
java·大数据·数据库
wdfk_prog2 小时前
嵌入式面试真题第 15 题:不可恢复异常后的通用崩溃快照、调用栈保存与离线分析架构
linux·开发语言·面试·架构
晴空了无痕2 小时前
从 Go 基础到 K8s:一条可落地的 Go 服务端成长路线
开发语言·后端·golang·kubernetes
神明不懂浪漫2 小时前
【第五章】Java中的继承与多态
java·开发语言
神州世通3 小时前
解密企业通信安全防线:Avaya Aura 三层安全架构深度解析
开发语言·php
AC赳赳老秦4 小时前
企业工商公开信息采集分析:OpenClaw 批量查询企业工商信息,生成企业画像报告
大数据·开发语言·python·自动化·php·deepseek·openclaw
AI多Agent协作实战派4 小时前
AI多Agent协作系统实战(十七):凌晨4点,我的AI系统在“假装工作“——3个bug同时爆炸的5小时
java·前端·bug
gaolei_eit5 小时前
Java+Ai+vue
java·spring·maven