当前位置:网站首页>"The programming is not standardized, and my colleagues are in tears!"
"The programming is not standardized, and my colleagues are in tears!"
2022-07-29 03:34:00 【Luo Zhaocheng CSDN】
First article CSDN(ID:CSDNnews)
There is a story in the programming world , That's to ask programmers what they hate the most 4 thing ? That must be :
Write notes 、 Written document 、 Others don't write notes 、 Others don't write documents .
Even worse , stay 《 Wandering the earth 》 After the screen swiping , Imitated “ Ten million lines of code , Comment first line ; Programming irregularities , Two lines of tears of colleagues ” Start to spread in the technology circle , This shows how painful it is for all programmers .
The author of this article —— Full stack developer Nitin Sharma Shared the seven sins of programming , Maybe it will enlighten you .
The following is the translation :
What's more interesting than doing it yourself ? Watch what you invent come into life slowly ? We humans , Is the Lord of all things , The Creator .
But in the digital age , The way of invention and creation has changed . Now? , We all create digital products . We build websites 、 Write software to meet our needs . Although our creativity is no longer dependent on our creativity , But we can still use the artist's name .
The world of programming is very broad , Involving multiple fields , We have many choices . You can choose to use functional programming , Or object-oriented programming ? You can choose to be a server or a client ? that , Do you have a choice in mind ? below , Yes 100 Programming languages , Can be used to meet your needs .
Language 、 frame 、 Libraries are growing . You can do the same code function in many ways . Although these languages may vary greatly , But most languages follow the same philosophy . therefore , They're going to have the same problem .
Here are seven crimes of programming , You can try to avoid them . Although I'm not a Christian , But I also like to define seven sins .
One 、 Do not use version control when collaborating
God bless! , We have version control tools . As I said , If we don't Git This version management tool , The world of code will be very difficult . Version control allows us to work together , It's very easy to modify or move .
imagine , We sit in front of the computer , Manually check and merge files , Save different folders for different versions . It's very inefficient , And it's very unreliable . Fortunately, , We have Git And other version control tools , To help us do this .
I've been involved in projects without version control , It was a nightmare .
Two 、 Do not use appropriate variable names
I don't know why? , There are always some people around , Use very short / Random names to name variables . When your project only 10-20 Line code , Or just code snippets , You can name it this way , But in big projects , Don't do that . Inappropriate naming , Fatal impact on readability and efficiency .
A simple rule of naming : The name of your variable can be self explanatory . When you see them , We know what they're used for . But don't use too long names ! Keep naming short , And readable .
Let's find out , In your code a , b, c Named code .
3、 ... and 、 Use too many dependencies , Upgrade without thinking
GitHub How many open source projects are there ? It's too much for us to count . These open source libraries make it easier for developers to work , Save our time .
But using too many dependent libraries will bring risks to the whole project . More dependent Libraries , It means longer compile time and run time . We should add the corresponding dependency library where we need to , Don't use it to use it .
therefore , Before upgrading , We need to check the dependency library often / Plug in support . I used to , The upgrade React, Instead of checking its impact on other libraries . Up to now , I still think it's one of the biggest mistakes in my life .
Four 、 Unexplained code
It is worth mentioning that , No one wants to read the whole method / Document to understand what it's for . Use minimal code to achieve functionality , But don't let others or yourself in the future , Hate what you write .
We should always try to write self explanatory code . We should let our code , When I was first seen , You know what it's for . To complete this code , We need to refactor the code correctly , Unified grammar , Appropriate variable name . When necessary , Also add comments to the code .
Of course , Don't write too many notes , You don't have to annotate every line of code . It is best to 1-2 Line notes , Write a clear overview or explanation of important parts .
5、 ... and 、 Inconsistent format
This is very similar to the fourth point , Inconsistent formats can also have a huge impact on readability and productivity . In the project , Choose a specific naming convention and stick to it , Don't change them halfway . I personally prefer to name files in capital letters , Hump nomenclature 、 Variable etc. . But they also change according to different languages .
There's nothing worse than developers formatting code .
Besides , In the code , We also need to use the same indentation format . According to your code style and selected language , Use 2/4/8 Space to indent . But no matter what format you use , Please insist on using it throughout the project .
6、 ... and 、 Do not handle errors
Fear it . Escape from it .Bug It will come. ! —— Thanos
( translator's note : finger Bug As the shadow follows the form , Endlessly , Like a curse .)
Here's the thing , No matter how good a programmer you are , You may have problems with your code , Unless you write code like this :
console.log("Yey")
printf("Wow")
These mistakes may be caused by API Caused by error , It could be a timeout , Type error , Null value , Or God knows why . Usually , This will cause problems in your code .
In different languages , There are big differences in the way errors are handled . But in general , Before accessing the data, you need to judge whether the data is empty . In my experience , There are more null pointers than other errors .
therefore , When performing data processing related requirements , It is recommended to put the code in try-catch in , And handle the corresponding exceptions , Last , Don't forget to tell the user where there is a problem . If there is no feedback to the user when the user presses the button and the key , Users will not know what happened . Give user error prompt , And tell it what to do next .
Always remember the words of extermination .
7、 ... and 、 Improper use of data types / data structure
In different languages , Different data type requirements , Strongly typed languages are very strict , The weak type can be used at will . A strongly typed language will tell you the error at compile time , Other languages need to be running , To know the mistake .
for instance , We store values in integers / Coincidence type / In the variable of double precision point type , And when compared to a variable stored in a string , Some languages have automatic type conversion , And then compare them , And some languages don't .
8、 ... and 、 Conclusion
Seven crimes of programming , Uncomfortable . We need to avoid it .
This is just a common mistake in programming . It's hard for you to see , A programmer , These problems arise in his program . But it's just like the seven sins in the Bible , It's not just these questions . They are original sin , Can be combined into different errors .
What other mistakes do you think need to be added to this list , Write it in the comments , Let me know .
Happy Coding!
Original address :https://hackernoon.com/the-7-deadly-sins-of-programming-a7574efc639f
边栏推荐
- Machine learning [numpy]
- 再学EXKMP(EXKMP模板)
- Example analysis of while, repeat and loop loops in MySQL process control
- Rongyun IM & RTC capabilities on new sites
- exness:鸽派决议帮助黄金反弹,焦点转向美国GDP
- (2022杭电多校三)1002-Boss Rush(状压DP+二分)
- Singleton and invariant modes of concurrent mode
- Environment configuration stepping pit during colab use
- Code speed optimization
- Makefile details
猜你喜欢

mysql的timestamp存在的时区问题怎么解决

ROS - create workspace

Excel拼接数据库语句

通过递归实现多级联动

Summary of basic knowledge points of C language

暴力递归到动态规划 01 (机器人移动)

Pp-yoloe details
![LeetCode 1331 数组序号转换[Map] HERODING的LeetCode之路](/img/be/d429d0c437dc5ed7cb4448e223a83a.png)
LeetCode 1331 数组序号转换[Map] HERODING的LeetCode之路

How dare you write a resume that is proficient in concurrent programming? Why do you use a two-way linked list in AQS?

Example analysis of while, repeat and loop loops in MySQL process control
随机推荐
Regular expression bypasses WAF
C obtains JSON format data asynchronously from the web address
3.2 model saving and loading
In depth C language (4) -- definition and use of switch
Anti vulnerability · benefit from uncertainty --- management?
GJB常见混淆概念
(codeforce547) c-mike and foam
力扣每日一题-第44天-205. 同构字符串
HDU多校第二场 1011 DOS Card
Use of leak scanning (vulnerability scanning) tool burpsuite or burp Suite (with installation and installation package download of burpsuite+1.7.26)
CUDA GDB prompt: /tmp/tmpxft**** cudafe1.stub. c: No such file or directory.
Reproduce 20 character short domain name bypass and XSS related knowledge points
Functions and comparison of repeaters, hubs, bridges, switches and routers
A simple and general method to obtain the size of function stack space
后缀自动机(sam)板子 from jly
(nowcoder22529c) diner (inclusion exclusion principle + permutation and combination)
Singleton and invariant modes of concurrent mode
Violence recursion to dynamic programming 01 (robot movement)
军品技术文件划分及说明
MOS管 —— 快速复苏应用笔记(贰)[参数与应用]