Twitter GitHub Facebook Instagram dirv.me

Daniel Irvine on building software

Navigating source code

29 May 2014

A funny [funny weird, not funny haha] thing about commercial IDEs like Visual Studio is that the file explorer is often displayed prominently at all times. This is funny because folder hierarchies are fairly useless when it comes to crafting source code. How you organize your files on disk just doesn’t matter. What’s far more important are the links between classes, such as method calls in and out of a class.

Most OO-language coding standards will suggest creating one class per file, and this fools a lot of programmers into thinking that they are navigating files, not classes.

Classes are rarely written in isolation. Often when you’re editing, you’ll be hopping from class to class. What you’re really doing is following links--from method to method, for example.

So why bother making that mental connection between class and file?

Instead, just highlight the symbol you want to follow and hit the key combination that will take you to its definition.

I’ve been figuring out how to do this in Vim with a Ruby project. Andrew Radev’s post Vim and Ctags has been a great help in understanding Ctags.

In the coming days I’ll be figuring out what my preferred workflow is here--I can imagine wanting to C-] into a new split pane for example, and that may require a key mapping.

Regardless, the only time a file name should be needed is when creating a new source file or when opening Vim.

About the author

Daniel Irvine is a software craftsman at 8th Light, based in London. These days he prefers to code in Clojure and Ruby, despite having been a C++ and C# developer for the majority of his career.

For a longer bio please see danielirvine.com. To contact Daniel, send a tweet to @d_ir or use the comments section below.

Twitter GitHub Facebook Instagram dirv.me