当前位置:网站首页>代码大全读后感
代码大全读后感
2022-06-29 16:07:00 【qq_1410888563】
一:80页:理想设计特征
1.最小复杂度

见解:
1.尽量减小复杂度,比如查询的时候可以用快排
2.用存储结构的时候,频繁插入删除用list,频繁查找用vector
3.不涉及到排序的时候尽量用unordered类型
4.for循环嵌套,小循环嵌套大循环
二:93页:信息隐藏的一个例子
有个程序,其中每个对象都是通过名为id的成员变量存储唯一的ID。
简单的方式就是设置一个全局变量g_id,其他对象构造的时候,简单使用id =++g_id;
正确的做法是:
设计一个接口
NewId() { return(++g_id);};
id=NewId();
三:93页:非标准语言特性

见解:
将外部库封装在函数里面去调用,而不要直接调用。
后面如果要替换起来也比较容易。
四:100页:耦合标准
有一个公用函数,需要两个参数,而这两个参数是某个类的数据。
这个函数的正确设计应该是用这两个参数作为函数的参数。而不是用类作为参数。

五:102页:语义上的耦合

见解:
如果有两个类,我们设计的时候,不能因为A知道B需要什么,就提供具体的操作,比如A有初始化init函数,然后A中有Run函数,Run函数无论如何都会调用init函数。然后B直接调用Run函数。A知道B实际上只用到7个初始化数据中的3个。所以A只初始化3个数据。这就是语义的耦合。非常危险。
正确做法:
B应该调用A的init,A中的初始化可以全部数据初始化,或者写一个函数专门初始化需要的3个数据。
边栏推荐
- TLBB series of Tianlong Babu - online single use database modified to other sects
- How to add a search box to your WordPress site
- 稳定币风险状况:USDT 和 USDC 安全吗?
- Notice on organizing the declaration of Nanjing innovative products (the first batch) in 2022
- Alipay "security lock" was selected as an excellent case in the "child care program" of the ICT Institute: more than 330000 users have opened game protection
- DTCC2022 中国数据库技术大会最新议程出炉
- 按键精灵打怪学习-多窗口多线程后台技能
- 如何在 WordPress 中嵌入 iFrame
- The difference between Magento and WordPress
- Self taught programming can understand the code, but what if you can't write it yourself
猜你喜欢

哪个版本的JVM最快?

Cortical traceability analysis of ERP

MySQL常用语句和命令汇总

论文笔记:E(n) Equivariant Graph Neural Networks

小程序在产业互联网有「大」作为

Sophon autocv: help AI industrial production and realize visual intelligent perception

稳定币风险状况:USDT 和 USDC 安全吗?

Summary of common MySQL statements and commands

隐私计算助力数据的安全流通与共享

京东方:随着下半年旺季到来、促销拉动、新产品发布等影响,需求有望出现好转
随机推荐
Flutter技术与实战(1)
技术分享| 融合调度中的广播功能设计
2022年有哪些适合穷人的理财产品?
基于JSP实现毕业设计选题系统
对于产业互联网的认识,直接关系着我们究竟会以怎样的心态来看待它
Small programs have a "big" role in the industrial Internet
Notice on organizing the declaration of Nanjing innovative products (the first batch) in 2022
MATLAB输出格式控制 %d,%f,%c,%s的用法
指南针开户炒股是否安全?个人怎样开户炒股
【Try to Hack】upload-labs通关(暂时写到12关)
Science: the interrelated causes and consequences of sleep in the brain
工具链赋能百家,地平线开启智能驾驶量产的“马太效应”
The third sprint of Wei long La Tiao: the growth rate of performance declined, and Liu Weiping and Liu Fuping cashed out in advance
MySQL基础——事务
挖财学堂证券开户安全嘛?
『计组』CPU 如何区分指令和数据
apache atlas断点查看
MySQL常用语句和命令汇总
Sophon AutoCV:助力AI工业化生产,实现视觉智能感知
实践 | 脚本错误量极致优化-让脚本错误一目了然