Love all the different examples. And the reminder to consider edge cases. It's easier to write pseudo code for an algorithms problem than for an application, showing both is a great way to see how you get from here to there :)
Interesting! I think it's really important to learn how to get past the blank editor problem - there's nothing more intimidating than a blank sheet of paper. I've not tried doing it with pseudocode.
I rely on writing a test first - identifying one behaviour of the program I want to write and imagining that I've already written it. What does it look like? What will it do? What function gets called? With what? What will it return?
For me, a test gets me solving one small problem, gets something down on the page and stops me fretting about everything else that's going on in the code/in my life/ on TV.
Does your pseudocode have an afterlife? Does it be become comments or do you tend to bin it once it's been replaced by code?
I think that's a really natural progression, and I normally write function declarations or tests first too. But, for beginners/jr devs, I think writing more traditional pseudocode is super helpful. It depends on the program, but I am normally minimalist on comments for simple code, maximalist on longer form documentation.
for your afterlife question, as it was recommended by steve mcconnell( software engineering expert ) Once the pseudocode is written, you build the code around it and the pseudocode turns into programming-language comments. This eliminates most commenting effort.
As a result the comments will be complete and much more meaningful.
I really like this write up Ali. I’ve done pseudo coding without knowing it actually had a term 😂. Mines is not as organized like your examples above, it’s more scatter brain but I try to outline what I may need to accomplish a task in bullet points or sentences.
Nice, I've always loved writing pseudo code as a starting point for programs or functions, usually just a piece inside the comments section, which really serve as a focus and guideline for what needs to be done. (And proof that you know what to do :))
Maybe one day all code will be written in pseudo code...mmm
Pseudo code is the first thing I've learn when I started my software programming course in school it's so useful for later!
Interestingly, way back in the Jurassic of computing (1970s) we were taught to always begin with pseudo-code; this was primarily because the means of getting the computer read our programs was punch cards, but it still makes sense.
great article, couldn't agree more.
pseudocode is definitely a very important practice, a by-product of which are great comments in the code.
if you write a concise version of pseudocode inside the code and then add the relevant code beneath it, you've just got yourself comments that will help you (or anyone else) who will need to maintain this bit of code in the future
Thanks for reminding us this basic but powerful concept!
Good bye blank text editor :-)
Such a great series!
This post is a game changer for me. Thanks Ali !
I love it! I write articles and focus on the problem solving part rather than a specific programming/scripting language.
I think it's pragmatic for solving leetcode. I'd try it when I challenge them.
I am never getting a dog
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.