轻量级前端框架助力开发者提升项目效率与性能
557
2022-10-12
C++核心准则边译边学-P.13: 酌情使用支持库
P.13: Use support libraries as appropriate(酌情使用支持库)
Reason(原因)
Using a well-designed, well-documented, and well-supported library saves time and effort; its quality and documentation are likely to be greater than what you could do if the majority of your time must be spent on an implementation. The cost (time, effort, money, etc.) of a library can be shared over many users. A widely used library is more likely to be kept up-to-date and ported to new systems than an individual application. Knowledge of a widely-used library can save time on other/future projects. So, if a suitable library exists for your application domain, use it.
使用经过良好设计,良好文档化,良好支持的功能库既可以省时,又可以省力。即使你花费主要精力去实现某项功能,支持库的品质和文档还是有很大的可能性会会比你做的好。支持库的成本(时间,劳力,费用等)可以被很多用户分担。一个广泛使用的支持库比单独的应用更有可能保持最新状态并且使用到新系统。(在一个项目上获得的)有关广泛使用的支持库的知识可以使我们在另外/将来的项目上节约时间。因此,如果在和你的应用领域中存在合适的支持库,就使用它。
Example(示例)
std::sort(begin(v), end(v), std::greater<>());
Unless you are an expert in sorting algorithms and have plenty of time, this is more likely to be correct and to run faster than anything you write for a specific application. You need a reason not to use the standard library (or whatever foundational libraries your application uses) rather than a reason to use it.
除非你是一个排序算法方面的专家而且有大量的时间,这段代码非常有可能比你针对特殊应用编写的任何代码都要正确并且执行地更快。
Note(注意)
By default use(缺省条件下使用)
The ISO C++ Standard Library(ISO C++标准库)The Guidelines Support Library(准则支持库)
Note(注意)
If no well-designed, well-documented, and well-supported library exists for an important domain, maybe you should design and implement it, and then use it.
如果在一个重要的领域中,不存在经过良好设计,良好文档化和良好支持的功能库,可能你应该设计、实现一个并使用它。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~