Project search vs My kitchen
On small-medium sized codebases, project search should not be necessary. A commentator on my last post wrote: “Replace ’/’ with Ack.vim…Problem solved? ” I disagree.
The argument is that:
a) given that it is relatively trivial to search the entire project for any given line, method, or file, b) therefore it is ok to have things be slightly harder to find
Going further, the argument is that:
a) given project search b) code organization is less important
This reminds me of how I recently organized my kitchen. Initially, everything was in mostly random places. If I wanted to find a spatula, it could be in one of three drawers, and I had to walk around to find it. If I wanted a pan, I had to walk across the room from the stove to a drawer.
I reorganized it so that everything that I use at any position in the kitchen is in the drawer right in front of me. Spatulas and things I use on the stove are in a little stainless steel by the stove. Pots and pans are directly to the right of the stove. The cutting board is close to the knives. Etc.
This kitchen refactoring makes my life so much better. I can focus on cooking instead of on finding things.
Before, I was basically “project searching” around my kitchen. The problem is that when you’re looking for a knife, it’s hard to find if it’s in a drawer full of other things. That is generally how project searches happen, you search for something, then have to look through at least 2 files before you find what you’re looking for.
Furthermore, you lose context. In the same way that I had to walk across the kitchen to get a pan and then walk back to the stove, by having to go into another place that project search takes you, you end up having to cycle back and forth between files to see the context.
Obviously, there is a balance somewhere. I have been using ack.vim for about a year now.
Having all your code in one file would suck. The idea is that whenever you want to do something, the tools you need to do it, and the things you need to change should be easily accessible.
February 23, 2011
