An often overlooked part of coding is pseudocode. Pseudocoding involves thinking about the steps to solving a problem and writing them in plain wor...
For further actions, you may consider blocking this person and/or reporting abuse
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.
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.
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.
Pseudo code is the first thing I've learn when I started my software programming course in school it's so useful for later!
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
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
I remember once during my graduation project, which was for a real client, I got stuck on some security bug for two whole weeks! One day at the office as I was panicking about lost time and the looming deadline, I grabbed a notepad and pen and tried to think it through. Lo and behold in just 10 minutes, I found the logical issue by writing out pseudocode and rewriting it and going through the logic in detail.
Needless to say I learned my lesson the hard way. Since then the very first thing I do before I write any code is write out the logic of the program in comments as pseudocode, and more complicated things I start them off on paper.
If you're stuck, pick up a pen! You won't regret it.
Having started to properly learn functional programming I noticed that pseudo code leads very naturally to finished code. For example your initial reversed_string pseudo code is almost a classic form of recursion as it stands.
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.
Such a great series!
Thanks for reminding us this basic but powerful concept!
Good bye blank text editor :-)
Thanks for this, always on point..
I am never getting a dog
I think it's pragmatic for solving leetcode. I'd try it when I challenge them.