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.

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

相关推荐
w2sfot1 小时前
Passing Arguments as an Object in JavaScript
开发语言·javascript·ecmascript
郝学胜-神的一滴1 小时前
避免使用非const全局变量:C++中的最佳实践 (C++ Core Guidelines)
开发语言·c++·程序人生
我没想到原来他们都是一堆坏人1 小时前
(未完待续...)如何编写一个用于构建python web项目镜像的dockerfile文件
java·前端·python
搞一搞汽车电子2 小时前
S32K3平台eMIOS 应用说明
开发语言·驱动开发·笔记·单片机·嵌入式硬件·汽车
沙二原住民2 小时前
提升数据库性能的秘密武器:深入解析慢查询、连接池与Druid监控
java·数据库·oracle
Jerry&Grj2 小时前
SpringBoot埋点功能技术实现方案深度解析:架构设计、性能优化与扩展性实践
java·微服务·性能优化·springboot·架构设计·埋点技术
没有bug.的程序员2 小时前
Redis Stream:轻量级消息队列深度解析
java·数据库·chrome·redis·消息队列
总有刁民想爱朕ha2 小时前
车牌模拟生成器:Python3.8+Opencv代码实现与商业应用前景(C#、python 开发包SDK)
开发语言·python·数据挖掘
用户8160791833332 小时前
告别“魔法”:包你解决 Gradle 的下载慢问题
java
小菜全3 小时前
uniapp新增页面及跳转配置方法
开发语言·前端·javascript·vue.js·前端框架