If you are like me, new to coding, or even someone that is a seasoned professional, you might need help saving time when coding. This can be for many reasons, missing files, lack of experience in the language you are working with, or the main culprit for me: not defining clear instructions for what my program is trying to accomplish.
If you are thinking, "Well, duh, that is a common problem for anyone trying to take information from the human world and trying to translate that into a programming language."
I understand and agree that it is an obvious thing to do when you want to solve any problem, but the challenge I want to pose here is, "Are you actually defining problems clearly?" Because I find myself wasting time working on code only to realize my errors when I stop to write clear intentions for the program.
Many beginners should pay more attention to the power of having clear procedural principles when overcoming the steep learning curve of coding. By having clear first principles, we positively affect the coding learning curve.
For example, we will often organize our day with a to-do list in a way that reads as follows:
Do the laundry
Walk the dog
Clean the bathroom
Finish TPS reports
If you notice that it looks pretty simple, you understand my point. If you contrast this with coding a program, you might paradoxically simplify things when defining the task so much that it is hardly worth writing down.
It might look like this:
- Write a function to find the number of vowel letters on a webpage
Now at first, it seems simple enough; you will use some way to iterate through the site's text so that you can count them. However, should you search the HTML only, or do we need to include the letters from Javascript and CSS? Or are we just looking for the displayed text the user will read when viewing on a browser?
Well, the display text for this program might be what we want, but if we didn't decide this is what we mean in our pseudocode or, worse, didn't write pseudocode, then our mind is already thinking about a bulk data parsing function instead of a precise function that collects only information about the displayed website text. If we are not clear on what we are trying to do from when we first write our pseudocode, then we are already likely in the weeds and wasting time.
Writing the task in a way that leaves so much open to interpretation can cause wasted effort and time. Imagine this simple project could take hours, and yet it is simple compared to the many moving parts you are of complex or large projects.
The profound simplicity of stating the problem you are undertaking in the most straightforward or accurate words possible can remedy the confusion that beginning coders may experience.
We can write a basic pseudocode like the one above but then detail the exact components to include in our program to fix this clarity problem for good. Doing this can save time, effort, frustration, and mental resources that can be used on other projects.
An example of a precise pseudocode could look like the following:
Write a function to find the number of vowel letters on a webpage
Exclude CSS and Javascript pages
Only parse the visible HTML elements like headers, paragraphs, head, footer, etc
Use a loop with conditional statements for regular expressions to parse the text a, e, i, o, u
Increase the counter variable by one when the letter is equal to a, e, i, o, u
This pseudocode example gives a clear set of instructions to write our program. We could be more detailed in writing the program components. However, it is a start for any beginning coders looking to shorten the time it takes to solve problems they are working on.
This way, we can follow the steps to completion, like how a baker follows a recipe to bake a cake or pie. At least for me, clear pseudocode instructions have proven invaluable, illuminating the path forward to a quicker and easier code-writing process.
Top comments (0)