DEV Community

loading...

Dr. Good-Habits or: How I Learned to Stop Worrying and Love Pseudocode

jakebrackney profile image Jake Brackney ・4 min read

// Opening paragraph with interesting hook

Four weeks ago, I took a leap of faith. I left my job in construction estimating and enrolled in a web development boot camp through General Assembly. The reasons for this are numerous, and I won’t go into them now, but I will say that I have experienced a rollercoaster of emotions regarding my decision, my understanding of the material, and my future in tech. In the four weeks since beginning this journey, not a day has gone by where I have not been reminded of one critical fact: I am new here.

// Elaborate on introduction

GA has been great. They are as invested in my success as I am. I have been reminded many times by my administrators that being new here, e.g. new in the Tech Industry, is not a bad thing. They’re here to guide me on my career path as I enter a truly massive industry and prodigies are rare in any field. However, no amount of guidance and career support will land me a job if I don’t work hard enough at understanding the material. It has been over 10 years since I’ve been in school. In order for me to succeed, I need to develop good habits. Enter: Pseudocode.

// Introduce main topic and establish conflict

When my class was first exposed to JavaScript, I didn’t write any Pseudocode. Not one damn line. Honestly, it was fine. We were writing basic arrays, loops, objects, etc. Getting intimate with the basics didn’t require me to create an outline of what my code needed to accomplish, because beginner code didn’t need to accomplish anything. After the second week of class we took a break for the holidays, and over the break I had four JavaScript assignments to complete. I'd hit coder's block right away. Not knowing where to start made it pretty tough to get anywhere.

// Elaborate on conflict

So, there I was. Two weeks into my education with a little bit of JS knowledge. We had just met the DOM and I was tasked with creating a table of contents in some HTML using only JavaScript. I wanted to knock out the assignment so I could get on with having a break. Immediately I found myself stuck. Like I said, it’s been a while since I’ve been in school. I’m still learning how to not dive right into writing code. I’m not at the point in my career (lol) where elaborate yet sophisticated lines of code will spew forth from my fingertips, through my keyboard and into my preferred text editor. If experienced programmers have taught me anything, it’s that I shouldn’t sit around waiting for that day to come. My success isn’t hinged on whether or not I can become a prodigy, right?

// Talk about the solution, with examples

I needed to create a table of contents writing only JavaScript and my instructors were kind enough to write an index.html file for me to work with. It contained everything I needed, articles, headings, class attributes, et al. My problem wasn’t that I didn’t know where to start. My problem was that my starting point seemed to broad. I needed to narrow things down. I only needed the headings. Once I came to that understanding I latched onto it, and from there, I wrote the first couple lines I needed to start the assignment.

// select all headings
const headings = document.querySelectorAll(‘h1, h2’)

After these first two lines I wrote pseudocode for all the remaining steps my code needed to take.

// select the empty <aside> element from index.html
// create a new element called list (ul), add it to the <aside>
// select the new list element
// create new list items for the selected headings and add them to the new ul

Just as Hemingway said in A Movable Feast, “The story was writing itself and I was having a hard time keeping up with it.” My code for this assignment wrote itself, because I knew what steps I needed to take. Once I had my outline, all I had to do was translate my pseudocode into JavaScript.

//Conclude

I’ve used capital-P Pseudocode on all my JavaScript projects ever since, which, if you’ve been counting hasn’t been long. The code doesn’t always write itself as easily as it did on that first assignment, but that’s a sign that I’m stepping into more complex algorithms. The pain and frustration I’ve experienced there is only a sign of growth. The more Pseudocode I write, the better understanding I have of where my code needs to take me and where it doesn’t. Every good story needs an outline. Like my instructors at General Assembly say, “Make it work, then make it pretty, then make it fast.” Step one: make it work. If I don’t know where to start, how will I figure out how to make it work?

//The End

Discussion

pic
Editor guide
Collapse
codingnspace profile image
Pearl McPhee

Awesome post, Jake!

Collapse
zfleischmann profile image
Zakk

This is a fantastic explanation for how Pseudocode is helpful! Thank you for sharing!