当前位置:网站首页>New year's goals! The code is more standardized!
New year's goals! The code is more standardized!
2022-07-27 08:47:00 【User 9925864】
The code is not standardized , Operation and maintenance two lines of tears
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 .
Try to do it before writing code know the score , Think clearly about the code framework . Now the world pays attention to pattern , The same goes for writing code . Answer these questions before writing code —— What is the core function of this code ? What needs to be realized to realize its core functions functions? these functions What should be designed accordingly class? these class How to inherit as much as possible , Can we inherit from the existing code base to avoid repeated development ?
Never write two lines if you can write one line efficiently . Take a simple one python Example , Want to get 0 To 10 An even number of , Most people will traverse +if Judge to write a few lines of code , But the result can be achieved by one line of code
y = [x for x in range(10) if x % 2==0]Document well . The job of a programmer is not to fall down after learning code , It also includes the document introduction of sorting out your own code , On the one hand, it is convenient for work handover , It is also convenient for me to report my work , On the other hand, it is convenient to clarify your thoughts , Prepare for future use of this code .
Sit upright , Protect your cervical spine . Old programmers know , How bad cervical vertebra affects work efficiency . Try to use a large screen when writing code , In this way, you don't have to bow your head to write , Sit correctly on the cervical spine 、 Old waist is good , Sustainable output is the king .
Setup Easy to use IDE Yield twice the result with half the effort . I am writing Python use Pycharm
Under the said Pycharm Some of the things used tips:
1、 The use of good TODO
Use for temporary code TODO notes , It's a short-term solution . Not perfect , But good enough .
TODO Comments should include... At the beginning of all ”TODO” character string , You can add a line of notes later according to your personal preferences , Explain what to do . The main purpose is to have a unified TODO Format , In this way, people who add comments can search for
# TODO(domi): Optimization threshold
# TODO(tony) : Adjusting variables If your TODO yes ” Do something in the future ” In the form of , Then make sure you include a specified date (“2009 year 11 Month to solve ”) Or a specific event (“ When all the customers can handle XML Request to remove the code ”). After you submit the code to GitHub When , It will prompt you todo Content , It's convenient for you to check your to-do list
2、 Code setting template
stay settings->Editor->file and code templates
# !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : ${NAME}.py
@Contact: xxxxx
@Usage :
@Modify Time @Author @Version @Desciption
------------ ------- -------- -----------
${DATE} ${TIME} domi 1.0 None
@TODO :
"""3、 habit Matlab Programmers are not used to it at first Pycharm, There is no way to view variables in real time to debug code , If you want to Pycharm Check the variable , Need to pass through Python Console, You can also use Anaconda Of Spyder modular , Develop interfaces and matlab similar , Real time view of variables
The recommended Google Style Code specification :
https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/contents/
边栏推荐
- ROS2安装时出现Connection failed [IP: 91.189.91.39 80]
- NIO总结文——一篇读懂NIO整个流程
- Implementation of queue (sequential storage, chain storage)
- Implementation of adding function of background user management display
- Realize SKU management in the background
- Day6 --- Sqlalchemy advanced
- 无法获取下列许可SOLIDWORKS Standard,无法找到使用许可文件。(-1,359,2)。
- redis的string类型及bitmap
- Bandwidth and currency
- 数智革新
猜你喜欢

无法获取下列许可SOLIDWORKS Standard,无法找到使用许可文件。(-1,359,2)。

VS Code中#include报错(新建的头文件)

微信安装包从0.5M暴涨到260M,为什么我们的程序越来越大?

E. Split into two sets

The following license SolidWorks Standard cannot be obtained, and the use license file cannot be found. (-1,359,2)。

数智革新

Realization of background channel group management function

Flink1.15 source code reading Flink clients client execution process (reading is boring)

Arm system call exception assembly

缓存一致性与内存屏障
随机推荐
4276. Good at C
3311. 最长算术
[nonebot2] several simple robot modules (Yiyan + rainbow fart + 60s per day)
Minio installation and use
Background order management
Block, there is a gap between the block elements in the row
List delete collection elements
4277. Block reversal
TensorFlow损失函数
Supervisor 安装与使用
Flask request data acquisition and response
After downloading URL loader and specifying the size of the image with limit, the image will not be displayed
List删除集合元素
tensorflow包tf.keras模块构建和训练深度学习模型
UVM Introduction Experiment 1
Cache consistency and memory barrier
03. Use quotation marks to listen for changes in nested values of objects
4277. 区块反转
Low cost, low threshold, easy deployment, a new choice for the digital transformation of 48 million + small and medium-sized enterprises
Flask one to many database creation, basic addition, deletion, modification and query