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.

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

相关推荐
计算机安禾几秒前
【数据结构与算法】第29篇:红黑树原理与C语言模拟
c语言·开发语言·数据结构·c++·算法·visual studio
叹一曲当时只道是寻常3 分钟前
Tauri v2 + Rust 实现 MCP Inspector 桌面应用:进程管理、Token 捕获与跨平台踩坑全记录
开发语言·后端·rust
独特的螺狮粉7 分钟前
开源鸿蒙跨平台Flutter开发:应对重症监护警报疲劳:BLoC 架构下的 FSM (有限状态机) 建模与全局消息干预机制
开发语言·flutter·华为·开源·harmonyos
lifallen11 分钟前
Flink Agent:ActionTask 与可续跑状态机 (Coroutine/Continuation)
java·大数据·人工智能·语言模型·flink
5720 天窗11 分钟前
classfinal加密Spring boot3
java·spring boot·后端·classfinal·class final
starsky7623811 分钟前
深入理解 Web 容器:从反射扫描到服务器启动的完整实现
java·前端·tomcat
路飞雪吖~13 分钟前
【测试】接口测试---1个框架,5个模块
开发语言·python·测试工具
sycmancia13 分钟前
QT——计算器核心算法
开发语言·qt·算法
AbandonForce17 分钟前
C++ STL list容器模拟实现
开发语言·c++·list
iuu_star23 分钟前
宝塔Linux部署python常遇问题解决
开发语言·python·腾讯云