In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what is the non-standard php code?" in the operation of the actual case, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Do not use version control when collaborating
For God's sake, we have version control tools. As I said, the world of code would be extremely difficult if we didn't have a version management tool like Git. Version control makes it very easy to modify or move when we collaborate.
Imagine sitting in front of a computer, manually checking and merging files, saving different folders for different versions. This is very inefficient and unreliable. Fortunately, we have Git and other version control tools to help us do this.
I've been involved in projects without version control, and it was a nightmare.
2. Do not use appropriate variable naming
I don't know why, there are always some people around me who use very short / random names to name variables. You can name your project in this way when your project has only 10-20 lines of code, or just code snippets, but don't do it in large projects. Inappropriate naming can have a fatal impact on readability and efficiency.
A simple naming rule: the name of your variable can be explained by itself. When you see them, you know what they are for. But don't use too long a name! Keep the naming short and readable.
Let's take a look at the code named a, b, c in your code.
3. Use too much dependency and upgrade directly without thinking
How many open source projects are there on GitHub? There are more than we can count. These open source libraries make the work of developers easier and save us time.
But using too many dependent libraries can pose a risk to the entire project. The more libraries you rely on, the longer the compilation time and runtime. We should add the corresponding dependency library where we need it, instead of using it in order to use it.
Therefore, before upgrading, we need to check the support of dependent libraries / plug-ins frequently. I once upgraded React without checking its impact on other libraries. To this day, I still think this is one of the most serious mistakes in my life.
4. Non-self-interpreting code
It is worth mentioning that no one wants to read the entire method / document to understand what it is for. Use the least amount of code to implement the function, but don't let others or later yourself hate what you write.
We should always try to write self-explanatory code. We should let our code know what it is for when it is first seen. To complete such code, we need correct code refactoring, uniform syntax, and appropriate variable names. Add comments to the code if necessary.
Of course, don't write too many comments, you don't need to explain every line of code through comments. It is best to write a clear overview or description of the important parts with 1-2 lines of comments.
5. Inconsistent format
This is very similar to the fourth point, and inconsistent formats can also have a huge impact on readability and productivity. In a project, choose a specific naming convention and stick to it. Don't change them halfway. Personally, I prefer to use capital letters to name files, hump naming methods, variables, and so on. But these will also change according to different languages.
There is nothing worse than a developer formatting code.
In addition, we need to use the same indentation format in the code. Use 2-4-8 spaces to indent, depending on your code style and language of choice. But no matter what format you use, please stick to it throughout the project.
6. Do not handle errors
Fear it. Run away from it. Bug will come! -- the destruction of hegemony means that Bug goes with him like a shadow, like a curse. )
The thing is, no matter how good a programmer you are, there may be problems with your code, unless you write code like this:
Console.log ("Yey") printf ("Wow")
These errors can be caused by API errors, timeouts, type errors, null values, or reasons that only God knows. Usually, this will cause problems with your code.
The way errors are handled varies greatly from language to language. In general, however, it is necessary to determine whether the data is empty before accessing the data. In my experience, null pointers have more errors than other errors.
Therefore, when performing requirements related to data processing, it is recommended that you put the code in try-catch and handle the corresponding exceptions, and finally, don't forget to tell the user what went wrong. If you don't give the user feedback when the user presses the button and key, the user won't know what's going on. Give the user an error prompt and tell it what to do next. Always remember the words of hegemony.
7. Improper use of data types / data structures
In different languages, the data type requirements are different, the strongly typed language is very strict, while the weak type can be used at will. Strongly typed languages tell you errors at compile time, while other languages need to know errors at run time.
For example, when we store values in integer / dot / double-precision variables and compare them with variables stored in strings, some languages automatically cast and compare them, while others don't.
This is the end of the content of "what is the non-standard php code?" Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.