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.

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

相关推荐
Joy T2 小时前
Agent 确定性上下文设计:从 Prompt 参数注入到能力分层
java·开发语言·微服务·架构·prompt·agent context
m0_587383005 小时前
广州 24 小时自助健身房解决方案技术实现与实战指南
java·spring·小程序·架构·需求分析
·云扬·6 小时前
Prompt 工程与安全:从 System 设计到注入防御
java·人工智能·安全·ai·prompt
专注仿真6 小时前
引擎扩展性与集成设计深度剖析:从 14 个扩展点到 DIS→HLA 演进之路
开发语言·算法·仿真引擎·推演引擎
Best-Wishes6 小时前
科来网络分析系统(技术交流版)使用说明书
开发语言·junit·php
代码不停7 小时前
自动化测试(java)
java·开发语言·selenium·自动化
鬼手点金8 小时前
opencode-rules 插件
java·开发语言·前端·人工智能·chrome·git·github
爱上网的小舟9 小时前
星际战士2启动错误怎么办?5种游戏报错解决方法
开发语言·php
paopaokaka_luck9 小时前
滑雪场管理系统(AI智能助手流式对话,ECharts 运营数据分析、教练、雪具与场地一体化预约,钱包支付退款、订单核销与服务评价)
java·人工智能·spring boot·网络协议·数据分析·echarts
阿里嘎多学长9 小时前
2026-10-12 GitHub 热点项目精选
开发语言·程序员·github·代码托管