šŸš€ Take the Ruby on Rails Community Survey and help shape the future of Rails!
Article  |  Development

Learning How to Learn: Simple Web Dev Efficiency Tips

Reading time: ~ 3 minutes

Learning How to Learn: Simple Web Dev Efficiency Tips

What is being a developer all about? Is it about memorizing syntax? Is it about being able to refactor inefficient code? Is it about making handy little shortcuts for yourself? Learning from the wisdom of the mighty developers here at Planet Argon has better equipped me with some tools to be able to answer these questions and I have come to learn it is all of these thingsā€¦and none of them.

When you are working with existing web applications that you did not originally build, each project has its own quirks and nuances. There are so many tools, languages, frameworks, libraries, etc. that you canā€™t possibly master them all, not to mention they are always changing. Development isnā€™t necessarily about what you already know, but rather about your fundamental ability to learn the next thing youā€™ll need to know to move forward.

Perhaps one of the most important ways to learn is to be efficient. When I started as an intern at Planet Argon I was still scrolling through applications looking for the thing I needed in each folder. I found myself searching as if I were still working in small tutorial-sized applications. However, real-world applications, with a large backend, are a different story.

It seems like a trivial thing to worry about tiny commands just to save a little time, but it really does add up.

Here are a few simple commands and tips to make you more efficient:

Command ā€˜Pā€™ will search directly for any file containing the word youā€™re looking for such as a model, or controller. For example searching for ā€œuserā€ to find User.rb.

Command shift ā€˜Fā€™ will globally search the application for any particular word you are looking for. If what youā€™re looking for isnā€™t in the name of the file but you arenā€™t sure where it lives this is your best option. Editors will usually have an area to specify a particular path as well so you can do a search only within a certain directory.

Command ā€˜Fā€™ will search locally within whatever file you are currently looking at. This is great when the file is massive but you need to find the location of something like a unique id.

So now you can save some time bouncing around the application in the editor but what about the terminal?

Donā€™t be a noob like I once was and type out full file names. Start typing the file name then press tab for autocomplete. For instance: If you know there is only one file that starts with a ā€œpā€ in your current directory then type ā€œpā€ and press tab and it will complete the file name. If there are more than one and you press tab it will show you which files exist that start with ā€œpā€.

What about finding some particular returned data in the terminal from a query of some kind? Say you are looking for a particular route relating to ā€œhome_pageā€ so you run ā€œrake routesā€ but you just get a mountain of routes which you have to scroll through until you see ā€œhome_pageā€.

Rather than putting yourself through that misery try grepping instead! Run rake routes | grep home_page this will make sure that your terminal only returns routes that contain ā€œhome_pageā€.

But what if that is not efficient enough for you? Why not conserve energy and save your tired little fingers? You currently have to type out rake routes | grep home_page every single time you want to search for that route. Well luckily you can create an alias! An alias is a short name that has a direct reference to a specific syntax.

Creating one is relatively simple. Youā€™ll need to save your alias somewhere, usually in .bashrc, .bash_profile, or if you are using Oh My Zsh (highly recommended) its stored in your .zshrc. Start by typing vim .bashrc. to open the file up in your terminal-based editor. Press ā€˜iā€™ to be able to write in the file. You can name your alias however you want, in this case Iā€™m going to name it ā€œgreprā€ so Iā€™ll remember that means ā€œgrep routesā€. Type out alias grepr=ā€œrake routes | grepā€. Press esc to exit insert mode then type ā€œ:wqā€ to save to the file and exit the editor. When you close, reopen your terminal and navigate back to your applicationā€™s directory you will be able to type grepr home_page and it will behave exactly the same as rake routes | grep home_page.

If you can find what youā€™re looking for faster youā€™ll have more time to investigate whatever weird issue you are trying to solve. If you are new to development hopefully some of these tips help you in your own journey. Keep learning and stay cool!

Have a project that needs help?