Organizational Skills in Programming: Planning, Pseudocode, & DRY

Mary Dick
4 min readOct 2, 2020

--

When I chose to pursue a career in programming, I had countless questions and concerns bouncing around my head. I wondered if I had what it takes to excel in such a complex and competitive work environment. As I began to learn more about the expectations that need to be met as a programmer, I realized that a huge part of gaining success in the coding world is building on my organizational skills.

1. Plan Out Your Code

Although I am still in the earliest weeks of my journey at Flatiron School, I have already learned so much. One of the strategies I use to make building on my code effortless and speedy has been to plan each step of my programming process in depth. Before I even write a single line of code I make sure to have a thorough plan for each class, method, variable, etc. I lay out my goals for the project and how I would like the project to be utilized by a user. I also make sure to create and name any files that I know I will need for my program. I also try to name any objects with simple, readable names, not only so that I can easily remember each one as I code, but also understand their purposes within the code when I look back on it.

2. Pseudocode

Once I begin to code, I often write pseudocode that is based on the plan I had previously formulated in the file that I’m working in.

For example, if I had planned for my method #create_username to take in the user’s desired username and assign it to the current User instance, I would write a comment in the line above where I am writing my #create_username method in pseudocode:

This not only keeps me on task while writing my methods but also provides an explanation for how the method should behave for the sake of my future self as well as collaborators.

3. Keep It DRY

Additionally, in order to stay concise and organized, I keep my code DRY; a common guideline for writing methods that many programmers live by. DRY stands for Don’t Repeat Yourself; you may find yourself repeating the same line of code several times in your program, in order to keep your code DRY, you are much better off writing a method to perform the same task.

For example, if you need to iterate over several different arrays and return a new array of just the odd numbers, you might write the following:

Although this code works, it’s a bit repetitive. We want our code to be versatile, concise, and readable; DRY.

In creating a method called find_odd_numbers(), we are ensuring that when we need to find all of the odd numbers in an array, we don’t have to iterate over each array every time, we can just call our new method to do all of the work for us! This also aids the reader in understanding what our code’s intention is.

Although it performs the intended task, the following code may be confusing for someone that isn’t familiar with Ruby syntax:

array.select {|num| num.odd?}

In order to make our code readable for all levels of Ruby expertise, we create a new method whose name states its purpose:

find_odd_numbers()

Finally, once I have everything written out and tested, I read through it and do my best to optimize my code. At this point in the process, I look for any code that might be confusing to read or that contains enumerators or methods that could be replaced by a better-suited one. This last portion is usually the least time-consuming when I follow the guidelines listed above.

Conclusion

If you stick to these steps in your programming process you will hopefully find it to be much less confusing and more streamlined than before!

Definitely still take breaks, though!

--

--