My first python web development framework (5) -- preparations before development (knowledge about coding), pythonweb
It's time to eat at noon, and Tom hurried to the location where the old dish sat.
Tom:Boss, invite you to dinner at noon.
Old dishes:Haha... you have another problem. This time, you have to beat it.
SmallWhite:As long as you enjoy your face and eat rice, you can chat while walking.
......
SmallWhite:Boss, I have finished all the methods you mentioned last time. Step by step, the direction and organization are much clearer. Now we are about to enter the encoding, so I 'd like to give you some advice.
Old dishes:Well, I am doing a good job. You can also teach me.
Some coding-related content is also commonplace. It is like a tall building. If there is no design drawing and no foundation is laid, you can imagine the quality of the building. Pay attention to the following points:
1. coding specifications
For this, python has done a good job and has a unified standard PEP8 guidance. You only need to do it as required. Of course, there are two points worth attention, first, naming must be based on meaningful and readable English words. Second, the code comments should be clearly expressed and annotated as much as possible, otherwise, you will know the pain points when you re-maintain the old system.
2. Moderate code Encapsulation
To put it simply, you need to put code with the same or similar functions in a unified file and call it to other places that need to call the same function.
For example, we often need to use MD5 for encryption. It is impossible to import the hashlib package every time it is used, create an instance object, and then perform corresponding processing based on whether the encrypted object is bytes or string, in this way, there will be a lot of repeated code. If you want to modify it in that place, you have to modify all the codes that use MD5 encryption. If you forget it during the processing, the problem may occur. Therefore, we put md5, base64 encoding and decoding, aes encryption and decryption and other content in the encryption operation package encrypt_helper.py, which is very convenient for use.
Import hashlibdef md5 (text): "md5 encryption function" md5 = hashlib. md5 () if not isinstance (text, bytes): text = str (text ). encode ('utf-8') md5.update (text) return md5.hexdigest ()
Why moderate encapsulation? If the code is over-encapsulated, the readability of the code will be reduced, making the code difficult to understand, so it is better to be moderate. Of course, it may be hard for beginners like you to understand at the beginning. Don't worry, you just need to implement functional requirements based on your own experience, after you complete this project, you will find that a lot of code can be reused, and you need to encapsulate and refactor it. Then, it will be easy to understand and improve your capabilities.
3. Classification of Program Files
If your project files are placed randomly, it will be very messy when there are more and more program files, and it will be very difficult to find some functional functions, so make a good plan before development.
For example, put various tool and function packages in the common folder, config put various configuration files, and api put various interface files.
4. Object-oriented
Understand what is object-oriented, understand the principles of object-oriented, and apply them to coding.
5. Manage development documents
During development, write and maintain various development documents, such as prototypes, data dictionaries, business flowcharts, and interface documents, you also need to maintain Gantt charts, Development Progress Management tables, various constraints, analysis, meeting notes, and other documents.
Of course, small projects do not need to be so complicated and do not maintain them. In general, there is not much problem. If possible, it would be better to maintain the interface documentation. Otherwise, during secondary development or development cooperation with others, that's it...
Common interface documents are recorded using wiki. There are many open-source and free wikis on the Internet, which are easy to install and use, such as ShowDoc.
6. Code Version Control
Although it is a small project, it is better to use version control such as SVN or Git. Projects that do not have version control are sometimes written. When I want to roll back previous versions or code problems, I have
7. Evaluation and Control of development time
Small projects should not be too keen on time management. Sometimes the delivery time is too long. If the project has not been developed yet, it will be miserable. How to evaluate and control the project development time is also very exquisite.
When you start a project, the project is usually divided into every page and interface, or even more detailed, and these development tasks are assigned to individuals, with these detailed tasks, it is much easier to evaluate the specific development cycle. During the evaluation, personal development time control is related to the content to be processed on each page and interface. What technical difficulties and solutions are required; or what business processes are involved in these pages or interfaces, whether they are clear, whether there are problems with the flow, and so on. This means that the code has been easily written in the brain before development, so the estimated time is generally no different.
Project control involves project management, so it will not be extended here. If I talk about it one by one, it will be endless.
Well, it's time to go to the place where you eat. I have to check which one is expensive and not enough.
SmallWhite:Boss, Big Brother. Be careful !!! You know, the younger brother is shy. let me lose my wallet !!! After receiving the project fee, please eat a big meal. Otherwise, I have to eat instant noodles every day for the rest of the day. Well, I think this is good. I often come here, go here ......
Old dishes:@.@
Author: AllEmpty
Source: http://www.cnblogs.com/EmptyFS/
If you are interested, you can addPython development QQ Group: 669058475. Let's discuss it together. If you have any questions, you can ask questions in the group. Of course, if I am busy at work, I may not reply in time.
This article isAllEmptyOriginal, you are welcome to reprint, but you must keep this statement without consent, and provide a connection to the original article clearly on the Article Page, otherwise you will reserve the right to pursue legal liability.