Just Because You Can Multitask Doesn’t Mean Your Methods Need To

Matt Borgman
Jan 12, 2017 · 2 min read
Image for post
Image for post

I’m a student at the online coding school Launch School. One of the things I have taken to heart in my short time with the program: a method should do one thing.

Before I came to Launch School I would come up with very lengthy and convoluted methods (or loops), they would be difficult for anyone else reviewing my code to decipher what the main purpose is. Now I know (and am working on making a standard practice) that my methods should be simpler. It is better to have more methods with an easy to understand name, and that does one thing clearly, than a method named ‘x’ that is 30 lines long and does 10 things.

To be fair, just knowing this does not make it happen in your code overnight. You still have to work at it as I am doing in my most recent project. For example, I am currently refactoring my Twenty One Game program, the main issue is that my main loop that runs the code is very long. Yes it is the main loop but the more I go over it the more ways I find to add in small methods to break it down further and further. This adds readability for the next person who works on the project, and for me if I come back to this code in 6 months or even 6 days.

So if you thought that was brilliant, you’re welcome, I hope it helps you with your future projects. If you already knew this, awesome! Hopefully next time I will have something closer to your skill level. I plan to keep coming back with tips/tricks/and concepts that I am learning on my journey at Launch School!

Thanks for sharing the adventure with me, and if you too are learning / teaching yourself to program, don’t give up on yourself. We all struggle, and it gets hard for all of us. But if you keep on pushing yourself you can do it! And remember we all feel like this all the time.

Image for post
Image for post
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store