My first pseudocode lightbulb!

chris_church

Chris Church

Posted on July 19, 2022

My first pseudocode lightbulb!

The exercise was simple, almost so simple that I didn't even get it at first. I'm new to coding, so this is purely speculation, but I started where many others have already been. Reading an article about writing pseudocode for putting away plates and bowls. It all seemed kind of silly and pointless at first. Code for separating dishes and putting them on the shelves? Place the fancy plates on the top shelf, the plain plates on the bottom shelf, and the bowls on top of the plain plates? What am I reading? How will this help me create a website or software? After struggling through the article it was my turn. I had to pick a topic and write my own pseudocode. I leaned back in my chair and thought about a topic. I want this to be good enough that it looks like I tried but I also didn't want to complicate the task because I really didn't see a point in it, other than I'd been told to do it. I landed on the idea of hanging up clean shirts. I started copying the format from the example and wrote my own pseudocode.

//Algorithm: Hang clean shirts
//Tasks:
//Remove clothes from dryer
//Separate shirts from other clothes
//Separate dress shirts from T-shirts
//Hang dress shirts on the left side of the closet
//Hang T-shirts on the right side of the closet.
//Abstraction:
//Ignore pants
//Ignore shorts
//Ignore socks
//Ignore dryer sheets
//1. Event 1: Hang shirts:
// Conditional: If (a shirt is a dress shirt) {hang it on the left side of the closet}
// else {hang it on the right side of the closet}
// Debug: If a shirt is wrinkled - what do we do?
// Conditional: If (a shirt is wrinkled) {put it on the ironing board to be ironed}
// else (shirt is a dress shirt) {hang it on the left side of the closet}
// else {hang it on the right side of the closet}

I assumed the task was complete and I didn't feel like I accomplished much. I saved the document and headed for the shower. While washing my hair, I had this flash of a thought. My code is incomplete. I potentially have a pile of wrinkled shirts on the ironing board and my goal was to hang up the shirts. My mind lit up with excitement. I was engaged in the process. I understood why pseudocode is so important. I remembered reading something about a loop. I thought about the process for a minute and ran a couple ideas in my head. Maybe I should change the ironing board to a steam setting on the dryer and start the process over again. Maybe the ironing board would help ensure the wrinkles are removed and that would make it the better process.

After deciding that I would stick with the ironing board, and finished showering, I went back to the computer and added my loop.

/2. Event 2: Iron shirts
// Loop: for(each wrinkled shirt) {iron shirt}
// If (a shirt is wrinkled) {put it on the ironing board to be ironed}
// else (shirt is a dress shirt) {hang it on the left side of the closet}
// else {hang it on the right side of the closet}

At the time of writing this, I can only assume that I've completed the task correctly. I've not shared my work with anyone at this point. I also realized that the blog I needed to write now had a topic. What first seemed like an impossible tasks has now given me the confidence that I will enjoy this new journey that I am. Now to figure out how to write a better blog...

💖 💪 🙅 🚩
chris_church
Chris Church

Posted on July 19, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related