Effective searches
Being smart about searches is key to exploring large codebases. You have many approaches to take to get better searches:
One must exploit language syntax to get search results that don’t suck. Some examples for C++:
- To find out where a method is implemented, prepend :: to the method name. An example would be “::OpenPort” to find all implementations of the OpenPort method. The great thing about this trick is that it filters out the definition in the .h file, and it filters out users of the method (except for static callers).
- To find out where a method is called from, prepend the -> operator to your search “->OpenPort” will hit most of your callers.
One must also exploit code base conventions.
- In the Torque Game Engine there’s a scripting language. The engine exports functions to the language with a macro called “ConsoleFunction” or “ConsoleMethod”. So if I want to find out all of the console functions & methods available to me. I can use the following regular expression: “Console.*(” and get my list.
Some IDE’s (Visual Studio, Eclipse) will give you this information without these searches. Which is nice to use when they work and when it’s available. The great thing about these text tricks are they work everywhere that “Find-in-files”/grep is implemented.
You can get away without such tricks. But you’ll spend a lot more time parsing your search results for the information you really need. I’d rather spend that extra time slacking. ;) More tricks to come as I remember/use them!