当前位置:网站首页>Notes on the method of Construction -- Chapter IV cooperation between two people
Notes on the method of Construction -- Chapter IV cooperation between two people
2022-07-18 09:59:00 【fpn233】
《 Build the method of 》 note
Chapter four The two work together
《 Build the method of 》 note --- Chapter four The two work together
Preface
Code specification , Extreme programming (xp) , Pair programming , The different stages of their cooperation , Techniques for influencing others
One 、 Code specification, style specification
It's mainly written rules , principle : concise 、 Easy to read 、 No ambiguity
Indent
4 Space ,Tab The key will display different lengths in different cases
Line width
Now we can 100 character , In the past, some documents stipulated 80 character ( Previous computer / The typewriter displays the line width )
Brackets
In complex conditional expressions , Use parentheses to clearly indicate the logical priority
Broken lines and blank { } That's ok
Use “{” “}” To clarify the program structure , It is also easy to see in multi-level nesting ; Every “{” “}” Monopolize one line .
branch
Don't put multiple statements on one line , More strictly , Do not define multiple variables on one line
name
“ Hungarian nomenclature ”: Early computer languages did not do type checking , stay C in int byte char bool It's probably the same thing ; And in some strongly typed languages , There are strict requirements for types , Not suitable for this method ;
Pascal: The first letter of all words is capitalized
Camel: The first word is all lowercase , Then the words follow Pascal form ,lowerCamel
Common practice : All types / class / All function names use Pascal form ; All variables use Camel form ; Functions are represented by verbs or verb object combinations .
notes
Don't comment on how the program works (How), And explain what the program does (What), Why do you do this (Why), And what we should pay special attention to ;
Complex comments should be placed in the function header ;
Comments should be updated as the program is modified , A misleading comment is worse than nothing !
notes ( Including all the source code ) It should be used only ASCII character , Otherwise, the portability of the program will be greatly affected
Two 、 Code specification design specification
Programming 、 Relationship between modules 、 General principles for design patterns ( General principles independent of specific programming languages )
function
cardinal principle : Do one thing , And do it well
goto
It's better for a function to have a single exit , To that end , You can use goto,
Error handling
Processing parameters
stay Debug In the version , All parameters should be verified to be correct , In the official version , Yes, from the outside ( Users or other modules ) The parameters passed in , To verify its correctness .
Assertion (Assert)
The relationship between assertion and error handling : When you think something is certain , You can use assertions ;Assert ( p != NULL);
If you think something may happen , At this time, we need to write code to deal with the error situation
Handle C++ Class in
3、 ... and 、 Code review
Purpose : See whether the code solves the problem correctly within the framework of code specification
Four 、 Pair programming
summary
It contains const Explanation : use const Annotate read-only parameters ( The data that the parameter points to is read-only , Not the parameters themselves ); use const Labeling functions that do not change data
边栏推荐
猜你喜欢

npm install安装报错:gyp info it worked if it ends with ok如何解决

CAN Communication (1) - CAN Communication Physical Layer

160_技巧_Power BI 新函数-计算工作日天数

Leetcode-162- find the peak value (two points must be seen)
![Microservice architecture | configuration center - [config]](/img/0f/ddba593a01c72dcf68c7d8e923fab6.png)
Microservice architecture | configuration center - [config]

基于多码GAN先验的图像处理

Image processing based on multi code Gan prior

Flutter 模拟火箭发射动画

Answer the reader's question (6): how to analyze the single cell TPM matrix?

Recursive function, factoring
随机推荐
Shiro integrates redis to realize distributed session processing
Timeline and playable cause unity crash problem record
Perspective of 100 listed companies on the Beijing stock exchange: the new world of middle-aged men of science and technology
对象转换的问题
学习使用亚马逊国际获得AMAZON商品详情 API
MySQL logs: undo log, redo log, binlog
(board) trie tree template acwing835 Trie string statistics
Can communication (2) - can communication protocol layer
大型互联网应用的技术选型和决策,10 条成功与失败的记录
Network information viewing and configuration
Code change and invariance
mysql: command not found 找不到mysql命令
透视北交所100家上市公司:中年理工男的新世界
AWS Config
C语言_字符串拼接函数strcat使用及实现
Idea import jar package operation and XML file configuration file
Leetcode-240-search two-dimensional matrix II
10个打开了我新世界大门的 WebAPI
【物联网】WiFi基础知识 (二)【看评论区领取资料】
AWS Config