Sometimes you just get stuck. Your coding isn’t moving forward, and Googling only shows you stale GitHub discussions about things that clearly aren’t about your problem. You know your answer has to be somewhere on the internet, you just can’t get it to show up in your search results. So, what do you do? This article has 5 practical tips for when you are stuck as a programmer searching for answers.
Tip 1: Start with the language
A professional developer feels no shame when relying on Google to get a job done. In most professions, such as medicine and healthcare this is actively discouraged (never search for your own symptoms online). If you write code, you also write bugs or encounter difficult problems to which the solutions are not very clear. The chance of you encountering this bug or problem for the first time is very slim and there surely must be other developers that ran into the same things. If you get lucky (most of the time you will) the solution is readily available for you on the internet. Learning to find and use these resources is an essential part of being a developer.
When you search for the following, you may end up with all kinds of unrelated (or rather unusable) results:
combine 2 arrays
Instead, check out these results:
JS combine 2 arrays
ES6 combine 2 arrays
You may also use ES6 to indicate you want to see modern syntax options:
python combine 2 lists
Use what you know about the language. This query starts with /python/ and I replaced arrays with lists. Python has lists, not arrays, so use that knowledge to your advantage.
golang combine 2 slices
Search engines can entirely miss your point when you are searching for answers to your daily issues with the Go programming language. “Go” is a verb, so make sure to replace go with golang and you will find answers much, much easier.
Ok, one more general remark. If you know how you want to combine the two data structures, use the right word if you know it. I mean instead of combine, you can use merge, concat(enate), zip, etc.
I program a lot in Elixir, which sometimes does weird things to my search results to be honest.
Tip 2: Mention the library (or stack)
Provide more context about your search if possible. The libraries you use are just as relevant as your programming languages when optimising your search results.
The following may not give you the best answer if you’re a VueJS developer:
render component to string
But this will:
vue render component to string
Tip 2.1: Alternatively, ignore a library
If you are interested in checking if a date is between two other dates, but don’t want to use the popular library moment, you can search for:
js -moment check if date is between two dates
- in front of “moment” to exclude it. See Tip 4 for more info on advanced search engine features.
Tip 3: Use the exact Error Message to get more context
We have all seen obscure errors like these. It is sometimes hard to find where they come from and even harder to find a fix for. Especially if they originate from a function call somewhere deep into a framework, they can make you bang your head against the wall at some point.
Search engines can be used as a bit of an oracle sometimes, though. Try this:
ReferenceError: h is not defined
TypeError: Only absolute URLs are supported
When you Google these errors, you get more insights in where they may come from. The first one either has to with Preact (a lightweight React-like framework) or Vue. The second one seems to be an error thrown by fetch.
You can then analyse your project further: what may use Preact in my project? Where do I (or a library I use) make fetch calls?
Tip 4: Use Advanced Search Engine Features
Search engines are quite smart, but sometimes they just get you all wrong. For example, you may be interested in Stack Overflow answers only:
site:stackoverflow.com React SSR
Or only interested in the official documentation that you know lives on GitHub:
site:github.com install helm
Check out Google’s tips on refining web searches.
Tip 5: Check Related Searches
At the bottom of your search results, there may be related searches by other users who may have found a better search query than yours. Check them out as you may learn something from them!
Search engines that track your usage learn from your search history. This means that over time, your Google results will become more relevant to you. If you just started out as a programmer, searching for programming related answers is actually harder than for seasoned programmers! To help you get relevant answers faster, you can follow the tips in this article. I hope you will find them useful!