This is useful for everybody. Whether you’re doing this for fun, you want to get a job as a developer, or you want to be a freelancer. There is more to software development than just writing the code, here are a couple of things you need to consider:
- Reading comprehension
As unlikely as it sounds, one of the biggest problems I’ve seen is the lack of reading comprehension. Combine this with the power of assumption and you’ll end up with a great piece of code that doesn’t do what it needs to do. Make sure you properly understand what is being asked of you before you start writing any code.
- Create a flowchart
This is the first thing I was taught before I wrote my first “Hello World!” back in '99. After you understand what is being asked of you, you need to create a flow chart. This concept is more important for beginners, once you have more experience you don’t necessarily have to do this but it’s still a good idea.
Why is this important?
- it reinforces your understanding of what needs to happen
- if gives you a roadmap of what to do
- it helps you understand what are all the possible outcomes
What are the common problems of not doing this?
- you start writing code, as the code evolves you realize you missed something and now you have to change half of what you already wrote
- you don’t know what all the possible outcomes are, most of the bugs found in code are related to “I didn’t think about that” or “that’s not what it’s supposed to do”
You need to account for all possibilities because the end-user will always try to do something outside of the happy path. This provides better user experience and makes it less likely for your app to crash.
Ever wonder when to add a for loop? Or maybe instead of a for loop it can be done with a switch? The flow chart will give you a good indication of what to use when.
Here is the most basic flow chart of all, which can be used for any application.
You have an input, something happens, then you have a result. As an example, let’s use a calculator.
Simple enough, right? But what happens if I provide a letter as an input? I need to make sure it’s a number or it won’t work. So, I take the process block and break it down.
I have to make sure the input is an integer. Therefore, I need to add an if statement to my code.
You can break down every piece of a flow chart as much as you want, in the end it will tell you exactly what code you need to write. Once you have all the pieces of the puzzle, you can write all your classes, functions, constructors, what have you. The flow charts tell you how to put it together. After you put it all together, you can use it as a validation tool to make sure your program is doing everything it needs to do.
There are many tools for creating flowcharts, I used Google Drawings for these examples. I really miss using Microsoft VISIO, the first time I used it was on a laptop that was running Windows 3.11… it was very bulky, but it was my first laptop and I loved it. However, doing flow charts by hand is also very useful, I find that writing things down reinforces all the concepts being learned.
I’m very surprised that these concepts are not taught in courses, even at the college level. I’ve run into mid-level developers who have a degree in Software Engineering that could not build a flowchart for their code. I find that mind-boggling. It’s a very simple but quite powerful tool.