Have you ever felt unproductive, bored, burnt out or stuck in a block? Yes, I've gone through that during my earlier days of programming and sometimes, even now, especially when working on large projects (side projects or work related).
How did I overcome it?
As time passed by, one day, I asked myself: "How do I become productive?" and "How do I overcome this negative barrier and become much more competent and efficient at solving problems?". If you've ever questioned yourself about this, then this blog post is for you.
I have developed and learnt some strategies and techniques to overcome this negative barrier such as:
- Design - Code - Test - Repeat
- Write clean code and refactor it
- DRY i.e. Don't Repeat Yourself
- Prioritize your tasks
- Use the right tools for your project
- Read other people's code
- Work on side projects
- Read more books
Design - Code - Test - Repeat
During my earlier days of programming, I would give very less thought to the design or the structure of the project and dive straight into coding it. Thus, I produced a lot of errors, dirty code and a buggy mess. It would be okay for a small project but what if you are asked to build a software that is used in the Wall Street Stock Exchange to monitor real-time trading which involves 99.9% of accuracy and correctness and handles millions of transactions per second? Yeah, that's not going to turn out really well for you and your client.
- Gather your requirements and analyze them
- Design it using a pen and paper and brainstorm different strategies on how to solve the problem
- Build a prototype
- Try to make your program fail earlier as it is much easier to fix than later
- Document your work
It's like building a house, if there's no requirement analysis and design before building the project, you're more likely going to end up with a overly coupled and high cohesion software that also means your code will be harder to debug, harder to write and add new features and put it on production and very unlikely, it wouldn't perform really well.
Write clean code and refactor it
We have all been there, when we are trying to figure out:
- "What does this method do?"
- Why you wrote a huge class with methods that contain 100+ lines of code and that is hard to debug or understand it's original logic?
- That variable name that doesn't make any sense at all.
- Write clean and short blocks of code
- Write meaningful variable names, methods and classes
- Follow a Singleton Pattern
- Try to write methods that are less than 100 lines of code
These suggestions should help you as our minds can't really handle a lot of complex logic especially if you have a piece of code that's unneccessary long and complex which could be harder to debug. Good luck on that!
DRY i.e. Don't Repeat Yourself
Whenever you have tasks that are too mundane, repetitive or time consuming, consider automating that process which could save your time and help you focus your energy on solving the actual problem.
- You could build a Code Generator to speed up your process of building classes, objects, variables, methods and so on.
- You could write a script to create your project file structure with all the necessary folders and boilerplate code using Powershell (Windows) or Bash (Linux).
- You could build a dynamic webpage to display different content instead of building hundreds of static pages which might have the same way of displaying content as a dynamic one.
- You could write an automated test to look out for bugs and errors in your code and fix them quickly.
There are so many ways to automate your work and all you have to do is look for a specific pattern, especially if it's repetitive, in the problem that you are trying to solve..
Prioritize your tasks
We all need to prioritze our tasks in order to feel more productive every day.
- Keep a checklist and keep track of your tasks for the day.
- Solve problems that you feel is the most important as majority of the time is usually spent on solving the wrong problems.
- Try to refrain from multitasking as it could be inefficient.
- Step away from the keyboard and take a break every few minutes.
But please use these tips at work, don't ever take work to home, unless it's really urgent, as it could be a sign of bad management skills and which means you might need to restrategize the way you work in order to be more efficient.
Use the right tools for your project
No, it doesn't even matter because each of them has it's own pros and cons and is used for specific purposes or tasks but it is you who has to choose the kind of tools that you would like to have at your disposal.
Read other people's code
Seriously, it's one of the best ways to learn. As you read code, you might encounter:
- Different programming patterns
- New libraries or APIs
- New programming syntax or techniques
Some of those encounters might be new or even unheard of, research about them using Google and try to implement it in one of your projects (not on your work-related projects).
Reading code written by other programmers is very important as it will be helpful with code reviews, debugging and working on any open source project(s).
Work on side projects
To some extent, the projects you work on during office hours might not keep you too busy or challenge you enough, so instead, you'll have to spend some time working on side projects.
Now, for some people, they would enjoy their weekend and stay away from code after a long week of programming until next Sunday, I totally agree and yes it's fine to take a break as most of us might not have the luxury of free time but for those who do, by working on side projects, it doesn't necessarily mean that you should spend a lot of time on it, you can work on them for about 2-3 hours a week.
- You could learn how to use that new tool, library, API
- Build a small game
- Implement an existing algorithm
- Solve a math equation (for those who love math)
- Study on how to use Regular Expressions (very useful)
- Learn and experiment a new programming language or technique
By working on side projects, you'll be adding new skills to your existing skillset and that could help improve your career.
Read more books
Yes, you can find a lot of learning material in the form of tutorials, YouTube videos and online courses but nothing beats reading a book that is written by a good yet experienced developer as the author would tend to go deep and give a lot of insights as to why he/she chose to solve a problem in a specific/particular manner.
- The Passionate Programmer: Creating a Remarkable Career in Software Development
- Code Complete: A Practical Handbook of Software Construction
- Clean Code: A Handbook of Agile Software Craftsmanship
- The Design of the UNIX Operating System
Also, it talks about the journey of the developer as to how they succeeded, made mistakes and learnt from it during their career.
Hopefully, these tips and suggestions should have given you an idea on how to make yourself feel more productive, efficient and competent at programming.
Happy productivity everyone!