Add wechat: code_7Steps, note “enter the group”, invite you to join the technical exchange group crowded with big talent!
Most developers today have an image of coding as the use of computer language to achieve complex logic or mathematical formulas, so that the computer can follow our instructions to do the corresponding work.
Admittedly, there is nothing wrong with this understanding.
But real coding is about writing a language that not only machines can understand, but that humans can easily read and understand.
On the other hand, writing good code is like writing a good story.
First, you need to name your variables correctly, just like the tasks in the story.
Second, you need to use some esoteric or easy to understand words to make your story clearer.
Also, just using advanced algorithms in your code doesn’t make you a good coder!
When working with different teams and business units on real-world projects, we need to write clean, maintainable code, and even better code that works across functions.
In this article, we’ll look at some concepts and coding practices that are sure to help you in the long run.
1. Have the right visibility to the right people
Today, we live in a world that is exponentially more dependent on technology, as industries automate, optimize, and scale up their operations.
Especially in today’s work environment, the need for data-driven solutions is inevitable, and we need to consider object-oriented programming approaches to solving business problems. Appropriate abstraction and encapsulation is required to show different levels of visibility to different levels of business.
In business, it’s often said, “Customers only care about results, not algorithms!”
By customer I mean broadly, anyone who directly/indirectly uses your solution is your customer, either internally or externally.
It can be a co-developer, project manager, project manager, test team, or the actual customer itself, depending on what you do.
For example, when a customer goes to a milk tea shop to buy a cup of milk tea, he doesn’t want to know what the ratio of milk to water is, all he wants to see is a result.
2. Modular solutions
Put your code in modules.
Instead of giving a long script /jupyter notebook as your solution, use import modules.
Its advantages are:
- Keep things simple for clients and hide unnecessary details.
- Reusable
- Easier to collaborate
If you’re interested in creating your own Python package, check out the official documentation.
3. Create a version0 solution first
Start by creating a basic solution.
This will allow us to show some progress and start discussions, which will help you get early feedback from your customers.
Better to be wrong at the beginning than wrong at the end.
4. Version control system and logging
An understanding of version control systems such as Git is a must when you work as a team.
This will ensure that:
- Easier collaboration and versioning.
- Code backup
- Every line of code is traceable
Plus, having a log file to track your progress and errors will greatly reduce debugging efforts.
5. Plug and play
Creating a profile to enable/disable various features of the solution can help us in many ways.
If we have multiple possible solutions to the same problem and need to test all possibilities.
You need to debug a problem in a submodule that doesn’t require many other modules.
If there is a plug and play feature, you can simply disable them and avoid the time spent running modules that are not needed.
6. Trust people, not their code
One of the most important skills in real-world coding is defensive coding.
Defensive coding is a way of programming for the purpose of anticipating possible points of failure.
When you are part of a large project and you will be working with many other developers, you will have to create modules with external inputs, either the raw data itself or the processing output of other modules.
We need to anticipate the possibility of human error and real-world noise and try to deal with them.
The idea is that our solution should not crash, and if your module doesn’t work, you should log the error and continue.
Especially when working with AI projects, modules are expected to fail because of False positives. This doesn’t mean code should be killed, but it’s up to you to anticipate these errors and do something about them.
Therefore, doing exception handling is a critical part.
7. Don’t trust your code either!
Needless to say, we’re human, and human beings are fallible.
No matter how good a coder you are, always accept the possibility that you will make mistakes.
Once you’ve completed a module, take a break. Do something else, and then come back and look at your code.
You’ll be surprised how easily you can find errors and optimizations that you never thought of before.
Therefore, this also shows the importance of code review.
I’ve always practiced one principle:
The most effective way to improve the quality of your code is to look at other people’s code and let them look at yours.
8. Don’t get emotional about your code!
When you spend a lot of time brainstorming, learning new techniques, and solving a lot of problems, you tend to get attached to it because it’s something created by your creativity and intelligence.
Sure, this passion and creativity will make you write better code and solve complex challenges, but there are some downsides.
You overexplain the beauty of your algorithm to your clients, and they don’t really care.
In an evolving business landscape, anything can change in a day. You’ll be asked to drop everything you’ve done for the past year and start a new project, and developing an emotional attachment to your code can make this difficult.
It may sound silly, but it’s a real thing, and even after working in the industry for more than three years, I sometimes struggle with this issue.
9. Pursue perfection
Finally, accept the fact that perfection is impossible to achieve, only to pursue.
No matter how good you think your code is today, if you’re going to look at it in a month, you can think of ways to make it better.
But if you strive for perfection, you will achieve excellence.
10. Conclusion
Most of the ideas I discuss in this article apply not only to coding, but also to life.
As Jobs put it:
Everyone should learn computer programming because it teaches you how to think.
Dry recommended
In order to facilitate everyone, I spent half a month’s time to get over the years to collect all kinds of iso technical finishing together, content including but not limited to, Python, machine learning, deep learning, computer vision, recommendation system, Linux, engineering, Java, content of up to 5 t +, all dry goods send to you, hope to be able to support a thumb up!
Pan.baidu.com/s/1eks7CUyj…