DEV Community

femolacaster
femolacaster

Posted on • Updated on

Writing Your First Pseudocode: A Body Fitness Analogy Part 1

Pseudocodes are algorithms written in natural/human language. An algorithm is simply a description of a process in an idealistic manner. Like every other idealistic endeavour, writing an algorithm is a creative process.

Unlike programming, you are not limited by pitfalls of programming languages and paradigms. You are free to take your brain to the weirdest of thoughts and that is why as you grow as a software developer, your algorithm knowledge may be a yardstick to judge your thinking ability.

There are a bunch of ways you can represent algorithms such as flowcharts, scenario diagrams, sequence diagram, interaction designs and much more. Why then should you consider pseudocodes? These are some of the benefits of pseudocodes:

  • Pseudocodes bring out the true idealistic nature of algorithm writing. You don’t have to concern yourself with rules on shapes, arrows, letter representations and many other “many many” as creativity thrive better in a situation of fewer rules. Pretty much what you would worry about is indentations for readability. And damn! You can go ahead and form your own rules. Pseudocodes won’t judge you.

  • Are you a product designer and the programmer isn’t just getting the idea? Pseudocodes are better interpreted by software developers. Statements are clearer since they are written plainly in human language and less ambiguity is prevented.

  • When trying to implement a process with a programming language you are not familiar with, pseudocodes come in handy. You can create your perfect process with your pseudocode. And then start learning the ways in which that programming language handles each of the sub-processes in that process. That way, you get to work, learn and apply faster. And gain knowledge mostly on the things to accomplish the task. You can then decide to learn other parts of the programming language later. A smart way to learn to code, right?!

  • Pseudocodes are a perfect fit for code comments as they are written in human language and would ultimately describe blocks of codes.

  • Pseudocodes change the narrative that “it is easier said than done” to “it is easier said and done”. When your thoughts and imaginations of a process have been expressed simply in natural language, then it only makes development easier.

However, pseudocodes can be bulky than the actual code itself because of the natural language representation and this makes it unpopular among agile organizations who would rather prefer to focus on implementation rather than documentation/idealization. Don't worry about that though, because you can improve your pseudocode writing to be as concise and efficient as possible.

I would be giving an example of how to do that using a body fitness analogy.

Here, we have a problem before us to solve.

PROBLEM:

Bori, an overweight lady who works every day from 8 am to 5 pm or sometimes 3 pm is trying to stay fit. She has to wake up as early as 5 am to prepare to catch a cab. So, she has only late in the evenings to work out. By the end of 3 months, she wants to have the right BMI. Also, she plans to add weight in the right places to be sexy for her hot musician boyfriend all in the space of that time-frame.

SOLUTION:

Let’s help Bori!

We would write a simple pseudocode that describes a step-by-step process in solving Bori’s predicament in the next series.

Top comments (0)