«    »

The Power of Search

My appreciation of the power of search, particularly for developing software, has grown over the last few years. The wise use of search can significantly increase your effectiveness as a developer, acting like an amplifier or expansion unit for your brain. Search allows you to navigate faster, remember easier, and know more.

I spend most of my development time working within the Eclipse integrated development environment and have come to rely on several of its search features. One is the Search | References | Workspace action available for Java code. It searches the entire code base for uses of the selected language element, which could be a field, method, class, or annotation. I like to call this the Ctrl+Shift+G operation after its keyboard shortcut. I always use the shortcut rather than navigate the menu, so much so that I have told coworkers to "use the Ctrl+Shift+G feature", and then flounder trying to come up with the actual name of the action. Performing this operation has become as natural to me as scrolling up and down or using the Open Declaration action. (This uses the F3 shortcut, and yes I had to look up this action's name as well.) I use the Search | References | Workspace action a lot when I am planning to make non-backward compatible changes to a block of code. I will look at all the users of the code and determine how they will be impacted and whether the planned change will work for them.

Two other Eclipse search features I rely on are Open Type (Ctrl+Shift+T) and Open Resource (Ctrl+R). Both are navigational aids allowing you to look up a Java type (i.e. a class) or a resource (i.e. a file on the file system) by typing in the name. I consider these search features because as you begin typing a name, Eclipse dynamically lists possible matches – see the image below. You can even specify a search pattern using basic wild-cards. I use these features almost exclusively to find Java classes. As a result I seldom have to remember what package a Java class is in, and do not have to spend time navigating through the package hierarchy to find it.
Eclipse Open Type Dialog

The final Eclipse search feature I use frequently is the Search | File action that allows you to find files in your workspace containing specified text or Perl-style regular expressions. I often refer to this as searching the entire code base. I find this quite useful when working with non-Java code such as JSPs, SQL, and Unix scripts. I typically use this feature when I need to determine where a particular construct is used – for example, a database table that is being altered. The Eclipse Search | File functionality brings to mind equivalent tools that I use on Unix systems, especially the find and grep commands. The grep command in particular I find useful for extracting important information from large log file. These tools are even available on Windows systems via Cygwin.

Probably the most obvious search tool for developers is Google. While it is quite useful for looking up reference information on languages, libraries, or tools, I find it especially valuable for finding solutions to perplexing errors. There have been a number of times that I have entered cryptic error messages from the database or application server directly into Google and found a solution or workaround within a short period of time. I find it interesting that often these solutions do not come from the official support site for the application but from a third party forum or blog. Google in essence allows me to tap into the world's collective knowledge and experience shared across the Internet and extract the information I need.

Other developers have blogged about their use of search and how it helps them. Jeff Atwood has written about how the Windows Vista start menu lets you type to find what you want to run. Cedric Otaku has mentioned that his use of browser bookmarks has dropped nearly to zero since Google came along. In both of these cases, search acts as an aid to navigation and memory. Rather than remember where a program or website bookmark is stored in a hierarchical menu and then navigate it, just type it in and scan the list of search results.

For me, the effective use of search feels like an upgrade to my mental capabilities – as if I am accessing a larger mind. A significant portion of human cognition deals with pattern recognition and memory retrieval via associations, and this what search tools do. One analogy is that my personal memory acts like a CPU-based cache – it is quick to access, but cannot store everything. If I get a cache miss – a question that I cannot personally answer from my memory – then I can turn to search. It is a slower operation to formulate & execute the search and then find an appropriate result, but I am able to access the collective mind via Google or the entire code base via Eclipse. When I find an answer, it is uploaded into my cache (my brain) for further processing. One limitation with search is that you do not always find what you are looking for. It depends on whether the information is available and on how effectively you formulated the search phrase or pattern. It is annoying to have a search fail, but it is really no different from our own fallible memory recall.

The similarities between electronic search and our own mental capabilities suggests that search will be a significant component of human-level artificial intelligences. Witness the victory over humans of checker- and chess-playing programs based on their ability to search potential outcomes of moves. There is no need, however, to welcome our electronically-searching overlords quite yet. The effective use of search requires formulating search terms and analyzing results, which in turn requires analytical and problem-solving abilities that current artificial intelligences lack across broad domains of knowledge. Until that is achieved, we can focus on using the power of search to boost our own capabilities.

If you find this article helpful, please make a donation.

«    »