I usually write pseudo code first, then I code around it. The pseudo code becomes basic comments for my actual code.
I also make a simplified version with checkboxes that I put on our task manager for my superiors to see. They can then understand where I'm going with this task.
Great article !
I love reading your posts. I'm newer to programming and I appreciate how you cover a lot of things that aren't brought up in tutorials. I think pseudo-code is something I need to get in the habit of doing more. Especially if I step away from a project for awhile and come back to it.
As mentioned in another comment, I write my pseudo code as comments in my script / program and fill it in Afterwards.
So you know what you thought at this moment even a few years later.
And another people will understand what you did too :)
Thanks! I'm glad my posts are actually useful! 😊
I'm just new to coding and I love this approach. Thank you for this post!
I also think the academic pseudo-code is interesting
Thank you! I'm glad it's helpful.
Pseudo-code is a great tool for working with large code bases that you didnt write in the first place, especially if they are complex. Or your own, 6 months later after you've moved on! As a senior I'll often tell younger devs to pseudo-code a task and bring it back to me before writing code; if their pseudo-code is correct I know they understand the problem and have much higher confidence they will write correct code.
Yeah, but why not let them write real code and do a code review soon. It might cause a bit more work for you but it is safer and the junior will probably learn more. Coding is not like building a house. Code can easily be modified. Version management tools exist. Refactoring exists.
Different level of abstraction which allows for ultra efficient communication and review of logic.
I completely disagree.
Pseudocode might have made sense in the age of assembler, FORTRAN and C programming but nowadays the two main reasons for using it are probably:
Not mastering your programming language.
Not knowing about refactoring - nobody gets a non trivial task right at the first try. Code is not something you write once and never change it afterwards. But that's not a bad thing: Changing code is cheap if the code is clean.
Maybe there are some rare occasions where pseudocode does make sense but in most cases there are better tools to use when you are not yet ready to code: Draw diagrams write specification documents, talk to people, build a prototype, write unit tests (TDD).
What sucks most about pseudocode is that it will not provide any feedback.
Why does this matter to me after all? Because I think that it is much more helpful in the long run to put your energy into the real code.
I've been coding for about a year and a half, and today I bumped into a really complex task at work, which involved (as usual) reading another coworker's code. Luckily, I had read this post on my lunch time, and it really helped me to better understand the existing codebase (since I was able to grasp the logic behind the problem by using pseudo code). Thank you for sharing!
This a really great post Milecia! I use pseudo code all the time and have for years, particularly on a greenfield project where I'm staring at a blank page/editor just to get mu thoughts on the page in a logical format w/o the burden of syntax, frameworks, OS, and all the other details that one must consider in coding.
Even if I have the general design in my head, there are often some complex transformation or formulae that I need to literal walk through on paper to validate my thinking and firm up the approach. It gives me the freedom to express my approach in "brain language" rather than computer language which I find very freeing.
When I learned to program the second (I learned in junior high first, then forgot most of it lol), we used a tool called an IPO chart which stood for INPUT-PROCESS-OUTPUT which had 3 columns listing basically what you'd expect, but the process was often pseudo code (sometimes flow charts but only for the handed in homework lol). I often take the same approach today and I've been coding for 37y - One is never too experienced to not need a helping hand.
Thanks again - keep posting!
Hi, nice article but I'm a beginner and I know I should nail this habit in now. I'm doing a bootcamp and the exercises are getting a bit more challenging, when I try to write pseudo code, I get trapped by 2 things. 1) I come from a more academic background, lots of essay writing, and so my pseudo code never comes out in simple digestible chunks and 2) sometimes I am not even sure how I will need to do what I need to do and so I end up just jumping right in and playing around, I never go back to writing pseudo code and if I made any attempts if offers me no guidance, because I'm like learning on the go about what works and doesn't. Any advice on how to improve on this?
Yes, Pseudo-codes are exactly necessary initially as it would allow the team(s) to brainstorm broadly as opposed to jumping straight into code.....
I can barely remember the last time I had to write pseudo-code. Usually I did, when I had to write something really difficult to just imagine in my mind. Nowadays, the stuff I code are pretty simple
Why did you bother posting academic pseudo code? It ruins the opportunity to share the article to someone who is learning
It's just there as another example of what pseudo-code can look like and just how complex it can be if you need it. 🙂
Love it. Clearly is the best way to approach an algorithmic problem
What makes you think so? Does real code really suck that much? If yes, shouldn't we better find out why that is so and try to do something against it?
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.