Categories
Careers

Programmer Best Practices — Being Late and Writing tests

Spread the love

To be a professional programmer, there are many things that we have to do to be a good one. In this article, we’ll look at what to do when we’re late, and why we need test-driven development.

Being Late

Most of us will be late for something eventually. We may be late for various reasons, like not getting enough time for estimates. To manage lateness, we should tell everyone that we might be late- we shouldn’t give people hope and then disappoint them.

If we’re going to miss a deadline, then we shouldn’t rely on hope to get it done. Rather, we must have a fallback plan to deal with being behind. If people try to force us to change the estimate, we must stick with our estimate. We just can’t buckle under pressure to try to make the deadline. If we do, the product probably won’t be good and the code is most likely also going to be bad.

It’s impossible to solve problems faster, we get stuck and we probably can’t get faster. Over time this becomes risky. We’ll be tired and burnt out by the end of it if it lasts one. There is just no way to get something done well by rushing it.

Changing the definition of what it means to be “done” also isn’t good. We may want to move on faster by changing the definition of done but it is not good to do that. No one wants to see all the real work that actually isn’t done even if we say it is. The easiest way to define being done is to make sure that automated tests pass.

Helping Each Other

Programming is hard. Therefore, we need all the help that we can get. We can’t just put together some code and hope that it works. Instead, we’ve to design everything into well-organized pieces that don’t depend much on each other as it’s beyond one person’s ability to do it well.

We’ll certainly benefit from another programmer’s help and ideas. This means that we should help each other so that we can make all our lives easier. If they need help, it’s time for us to jump in. We should also accept help from others when we have problems. This way, we also get things done faster and better. Also, we should learn to ask for help- when we’re stuck, it’s time to ask for help.

Mentoring

Less experienced programmers need help from people with more experience as training courses don’t always cut it and sometimes books can’t help that much either. Receiving mentoring from more experienced programmers, on the other hand, can help with that.

Test-Driven Development

Test-driven development can help us a lot with writing code faster and better. We write the tests first and then we write our code. We write code to make the tests pass and then we’re done. First, we write a few tests and then we make them pass. Then we repeat the same thing for the rest of our project or tasks.

We get fewer bugs because we have the tests to catch them. If we have tests, then we wouldn’t worry about making changes because we can clean them up on the spot. The tests will make sure that our code is still good. Clean code is easier to understand, change, and extend. Defects are less likely because we simplified our code.

Documentation

The tests have descriptions to describe what it’s testing. This is a great source of documentation for us. It also shows us how to use some APIs in the code with the test code. The tests call functions, so we know how to use them. And they make requests, so we’ll know how to make requests with them if it’s a web app.

Design

To make code easy to test, we test them in isolation. This means that we have to decouple the code. This is great since we don’t want tightly coupled code. Therefore, writing tests first will help us improve our design. Most of the time, it’s practical to use test-driven development. However, there are some rare times that it’s not the case.

Conclusion

If we’re late for a project, then we should communicate that and stick to our timeline for finishing stuff. Getting and receiving help is also a great thing to do. Writing tests are great since they test our code and also serves as documentation.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *