Learning How to Learn: Simple Web Dev Efficiency Tips
Reading time: ~ 3 minutes
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!