English: Henrik Warne
Translator: Xiao Xie, columnist of Bole Online
Links:http://blog.jobbole.com/102562/
Here’s a list of some of the best things I’ve learned over the years in software development.
1. Start small and expand
Whether it’s creating a new system or adding new features to an existing one, I always start with a version so simple that it has almost no required features, and work my way up until I’m satisfied. I never dreamed that I could reach the sky at once. Instead, I learn as I develop, and the new information can be used in the solution.
I love this quote from John Gall:
“Complex systems always evolve from simple systems.”
2. Do one thing at a time
When testing fails and features don’t work during development, it’s much easier to get to the bottom of a problem if you study it one at a time. In other words, use short iterations. Make sure this problem is solved before you move on to another one. This applies to downward submissions. If you need to refactor code before adding new features, submit the refactoring first and then add new features.
3. Add logging and error handling early
One of the first things I do when developing a new system is add logging and error handling, because both are very useful from the start. It’s more useful to the system than a bunch of code, and you need some way of knowing the state of the program. If the system isn’t working, then you need to know what’s going on in the program — that’s what logging is for. The same goes for error handling — the earlier errors and exceptions are handled, the better.
4. Each new line of code must be executed at least once
Before you can actually finish a feature, you have to test it. Otherwise, how do you know if it’s working the way you want it to? Often, but not always, the best way to do this is through automated testing. However, each new line of code must be executed at least once.
In general, it’s hard for us to trigger something. But fortunately, we can cheat. For example, error handling of data can be triggered by temporarily misspelling a column name. Alternatively, an if statement can be temporarily reversed (from if error to if not error) to trigger conditions that would otherwise be difficult to trigger, just to determine whether the code is working properly and what will happen to it.
Sometimes I find lines of code that will never be run. When we do code checks it looks fine, but it just doesn’t work. You want to avoid this awkward situation if you want every new line of code to be executed.
5. Test the modules before testing the whole
It saves time to test some modules first. Generally speaking, we also have problems integrating different modules, such as interface mismatch between modules. But tracking integration issues is much easier if we can trust the components.
6. Everything always takes longer than you expected
Especially in programming, even if everything goes well, it can be difficult to properly budget the time required for functionality. And it’s not uncommon to encounter unexpected problems when developing software. A simple merge can lead to a bunch of bugs, a framework update means that some functions have to change or some apis don’t work the way you expect them to.
Hofstadter Law (HofstadterThe truth is that things always take longer than you think they should, even if you take Hofstadter Law into account in your expectations.HofstadterLaw).
7. Start with existing code
Most coding requires changing existing code in some way. Even new features need to be adapted to existing applications. So before you add anything new, you need to understand the current solution. Otherwise, you can easily break existing features if you’re not careful. This means that reading code and writing code are necessary skills. This is one of the reasons why seemingly minor changes can still take a long time to resolve, because you first have to understand the context.
8. Read and run code
Fortunately, there are two complementary approaches to understanding code. You can read the code and you can run it. Running code is a great way to do it. So make sure you take full advantage of both.
troubleshooting
9. Bugs are inevitable
I don’t like the hype that software development can be “done in one go.” No matter how hard you try, bugs are bound to happen (the definition of a bug is basically “we didn’t think of it”). It is best to have a system that can quickly troubleshoot, fix bugs, and deploy fixes.
10. Troubleshooting report
Every developer should take the time to deal with bug reports from customers and fix bugs. This gives you a better understanding of the customer’s intentions, how to use the system, how easy it is to troubleshoot, and how the system was designed. It’s also a good way to take responsibility for your own development. Don’t miss out on the benefits.
11. Reproduce the problem
The first step in fixing a bug is to reproduce the problem. And then you have to make sure that once you fix it, the problem goes away. This simple rule ensures that you don’t mistake a non-problem for a problem and that the solution actually works.
12. Fix what you know is wrong, and then see if anything else is wrong
Sometimes, there may be several different problems at the same time. Their interactions can leave you clueless and helpless. Don’t get caught up in trying to figure out what’s going on, fix all the known problems first, and then see what else isn’t right.
There are no coincidences
When testing and troubleshooting, don’t believe in coincidences. If you change the value of the timer, you change the frequency at which the system restarts. So none of this is a coincidence. Add a new feature and an unrelated feature slows down? This is definitely not a coincidence. Instead, it’s something you should investigate carefully.
14. Associate time stamps
Event timestamps can be a useful aid in troubleshooting. Look for even increments. For example, if the system has been restarted and a request has just been made for around 3000 milliseconds, a timer may have been triggered to cause the restart.
Face-to-face communication works best
When we need to discuss how to solve problems, face-to-face communication is better than video, phone calls and emails. I often find an exciting and better solution after discussing it with colleagues.
16. Small yellow duck debugging method
When you have a problem that you can’t solve by racking your brains, find a colleague and explain it to them. A lot of times, when you’re narrating, even if your colleague isn’t saying a word, you may suddenly have an Epiphany and get to the heart of the matter. It sounds like magic, but it often works.
17. Ask questions
Reading and running code is often very helpful in pointing out the purpose of the code and how it works. But if you have the opportunity to consult someone who knows better (for example, a former programmer), don’t miss it. Keep asking them specific questions, follow-up questions, and give you more information in a few minutes than it could take you days to get.
18. Share credit
Don’t go for the honor, it’s yours. For example: “Marcus came up with this idea…” (if he did) instead of “We came up with it…” . Don’t be afraid to name people who have helped or contributed to you.
19. Do it
If you don’t know how a programming language feature works, write a small program to understand how it works. The same goes for testing the system you’re developing. What happens if I set the parameter to -1? What happens if the service fails when I restart the system? To study how it works. Doing this regularly will help you find bugs and at the same time improve your understanding of how your system works.
Sleep with your problems
If you’re working on a difficult problem, sleep on it. There are scientific studies that show that while you’re not actually thinking, you’re subconsciously doing it. As a result, go back to the problem the next day and find a solution.
21. Change jobs
Don’t be afraid to change roles. It’s fun to work with different people, develop different products and experience different company cultures. In my opinion, too many people just passively stay in the same place working year after year and only change when they are forced to.
Never too old to learn
One of the great things about the software industry is that there are always opportunities to learn new things. You can try different programming languages and tools, read books on software development, and take MOOC courses. Believe me, quantity makes a great leap, these small accumulation of learning, will one day greatly improve your knowledge and ability.
About the columnist
X: Lazy programmer
Baichuan.taobao.com is the wireless open platform of Alibaba Group. Through the opening of “technology, business and big data”, baichuan.taobao.com provides high cohesion, open, industry-leading technology product matrix, mature business components and perfect service system in mobile scenes. Help mobile developers quickly build apps, accelerate the process of APP commercialization, and empower mobile developers and mobile entrepreneurs in an all-round way.