As developers, we search extensively on StackOverflow, our codebase, GitHub, Google, etc.
Doing this task as efficiently as possible to obtain the best search results can significantly improve our productivity as developers.
Moreover, since we have good tools and search engines, we can use them to our advantage and make them do more work for us.
So, in this newsletter today, I will share three tips I use every day that enable me to do searches as efficiently as possible while employing the tools we currently use in our favor.
π Query Google Search Tips
If we want to treat search as an optimization problem, which means we want to get the best-filtered result for our query, we must master Google-specific query-limiting syntax. Here are three different valuable approaches:
For example, if you want a specific term included in the result, you can annotate it with a βdouble quote markβ. For example, if I want Kotlin-datetime to be in the result pages with that exact spelling, I would type:
βKotlin-datetimeβ library.
Another excellent approach is to use the word site if you want to search for a specific website. For example, if you want the result to be only in StackOverflow or, say, Android documentation, then type
site:https://developer.android.com/develop broadcast receiver
. This will largely limit the results.Next, if you want results to be published after a specific date or before a particular date, say you know that concept only existed after 2022, you can use that information to largely filter the results with something like that:
compose theme after:2022-01-01
There are many other query settings you can set to make google work for you efficiently, check out more of them here.
π¦ IDE Search Tips
Next, we need to search your codebase for code you want to modify and add behavior to, and we also want to search for actions and specific items in your IDE.
If you are using Android Studio or IntelliJ, you can double-shift to search everywhere. This will search for code, functions, file names, class names, actions in the IDE, settings, and much more.
This is good if you want to execute something fast, but if you know what you want specifically, you can improve it by searching in the right context.
For example, Ctrl + Shift + F will only search text tokens in files, so itβs better in terms of performance compared to searching everywhere. It also gives you a new window to put your search results so you can be actively looking. I use this when doing significant refactoring that spans many areas.
Another cool feature in the IDE is regular expressions. This feature is useful if you have something complex you want to match in many files.
Here is a pro tip: Just give the thing you want to match to ChatGPT and tell it how general you want the regular expression, and he will give you a good one you can try.
Learning about the IDE is one of the cool investment you want to do to be more productive, and definly searching is one of those thing you want to learn.
Also, I am building a small course about Productive IDE flow; you can join the Waitlist here to hear updates about it and contribute to its final shape.
π§ Searching on Github
One last thing I want to share is using Github for code search. I've noticed that not many developers take advantage of this. As developers, we often search for code snippets. Where is it better to find them than on Github?
If you need something specific, it makes sense to search directly there. You would simply go to the search bar, type in some code (preferably), and then hit search to search across all of GitHub.
You can enhance this search further by limiting the language you are searching for. If you know where to look (repositories or organizations), this is much better, which makes the search more narrow.
Here is how I use it often: Sometimes, I use a library or framework to accomplish something, and I often search for how other people are using it. It might be big open source project or smaller other project, I take their example as input so I know how to do it in my project.
Also, I remembered I had a bad time reading something from the documentation that didnβt work on my machine, so I searched on Github for how the library does that inΒ real-world projects.Β I discovered that the documentation was wrong and that I needed to make a different use of the parameters that werenβt mentioned in the docs.
Not only that, but sometimes there is a fantastic discussion of problems weβre facing, so it makes good sense to search there and make it one of the main buckets we need to search on.
The beauty of this approach isnβt finding only what you need; you might also find good repositories that will make a difference for you. You might then recheck these repositories to contribute or simply observe how they are doing something. You will always have a source of inspiration like that.
Tips of the week π‘
This week, try to make optimized search a habit. Every time you search, think about how you can improve the search by using the tips here.
I know this will slow you down βfor the moment β but then hopefully you will be a search ninja who find things effortlessly.
π£ See you in the upcoming weeks with another Tip!
βοΈ Charfaoui Younes.
If you want a video for this newsletter, you can watch it down β¬οΈ
β
My preferred things this week
Here is a couple of digital content Iβve been consuming this week:
π¬ My YouTube Video: The Reason We Need Compose Keys!
π¬ Another YouTube Video: Gilded Rose Refactoring (1/4)
πΉ Article: The technology behind GitHubβs new code search.
π Book: I am reading Effortless by Greg McKeown.
You would make my day if you share this newsletter with other developers π.
π€ Here are other ways I can help you with:
π Work with me 1:1 - book a coaching or strategy session for 60 minutes.
π¨ Course: Refactoring Legacy Code Like a Pro: A step-by-step approach for refactoring messy codebases into a Software Masterpiece.
π₯ Check out my YouTube channel: Discover tips on Android, Software Engineering, and productivity for developers.