<commit_before>---
layout: post
comments: true
title: You need to learn to navigate code
categories:
- blog
---

# You need to learn to navigate code

Often when we talk about productivity of developers, we will measure various outputs. In the worst places, this metric might be lines of code. In better ones, it will be bugs density, features completed, support requests answered. Often, to get better at these we will reference things like better software design, maintainable code, unit tests,  and more. Some of these focus on letting other people read our code in a more efficient manner and others just help us write better code for ourselves. The best will do both. There is another side of the equation, though.  We write readable code because we know that eventually someone else will read it, even if that "someone" is ourselves.  The thing we neglect to also talk about sometimes is that being able to **read your code in an efficent way** is almost as important.

## Learn your IDE shortcuts and make use of them

This might sound obvious. It might even seem like it goes without saying.  However, I have witnessed many developers that simply do not use any hot keys or know the shortcuts to navigate their editor. They do not use any shortcuts. When you are reading a dense chunk of code, this can cost you minutes that will add up in a very long session. These days, I do mostly web development so I will be speaking mostly from that perspective. I use **Atom** and **Visual Studio Code** as my main editors  and feel comfortable talking about these. Even though I prefer **Visual Studio Code** more nowadays, I focus a lot on Atom since I think a lot more developers still use it. It's very popular and because of that, I feel like a lot of people use it without actually configuring it properly.  It is *is* possible that this phenomenon is exclusive to web developers but I have a feeling it can be applied to others, too. I feel like developers with full IDEs are more aware of these kinds of things, especially in languages like Java where the tooling has been very good for a while now.

These are some things you need to learn to use, else you are severely missing out:

1. **Jump to method **. If you are pressing `Ctrl + F` to find a method inside of your code, you are doing it wrong. Most IDEs and even text editors, such as Atom (with the proper language server / support) can jump straight there. For example, in Atom, you can do this with `Ctrl + R` (at least on Linux) There are numerous advantages

   * The search is often fuzzy, so you only need to recall a few characters
   * You can see all the symbols in one view, so you can flip through them fast if you need to often
   * You can get there by just typing some characters instead of scrolling and then positioning the cursor
   * You only get **definitions** and not all the usages as well and then need to read each result you get if you were to have done a search

   ​

2. **Go to file / class**. This is also a big one that I see a lot of people use already and it is rare that I do not see someone use it. Hunting for a single class or file in your structure is painful and could require dozens of seconds to get right, depending on how large your project is. `Ctrl + Shift + F` is not the right answer ==  instead, use something like `Ctrl + P` in Atom or `Ctrl + O` in Jetbrains IDEs. 

   You get something like this:

   ![https://www.jetbrains.com/help/img/idea/2017.2/gotoFile.png]()

   ... and now you get somethign that can help you find a file very quickly.

3. **If your tooling supports it, learn your quick navigation tools such as "Go to class" or "Go to definition" when you have a word selected.** Visual Studio Code has good support for this.<commit_msg>spelling fix<commit_after>---
layout: post
comments: true
title: You need to learn to navigate code
categories:
- blog
---

# You need to learn to navigate code

Often when we talk about productivity of developers, we will measure various outputs. In the worst places, this metric might be lines of code. In better ones, it will be bugs density, features completed, support requests answered. Often, to get better at these we will reference things like better software design, maintainable code, unit tests,  and more. Some of these focus on letting other people read our code in a more efficient manner and others just help us write better code for ourselves. The best will do both. There is another side of the equation, though.  We write readable code because we know that eventually someone else will read it, even if that "someone" is ourselves.  The thing we neglect to also talk about sometimes is that being able to **read your code in an efficent way** is almost as important.

## Learn your IDE shortcuts and make use of them

This might sound obvious. It might even seem like it goes without saying.  However, I have witnessed many developers that simply do not use any hot keys or know the shortcuts to navigate their editor. They do not use any shortcuts. When you are reading a dense chunk of code, this can cost you minutes that will add up in a very long session. These days, I do mostly web development so I will be speaking mostly from that perspective. I use **Atom** and **Visual Studio Code** as my main editors  and feel comfortable talking about these. Even though I prefer **Visual Studio Code** more nowadays, I focus a lot on Atom since I think a lot more developers still use it. It's very popular and because of that, I feel like a lot of people use it without actually configuring it properly.  It is *is* possible that this phenomenon is exclusive to web developers but I have a feeling it can be applied to others, too. I feel like developers with full IDEs are more aware of these kinds of things, especially in languages like Java where the tooling has been very good for a while now.

These are some things you need to learn to use, else you are severely missing out:

1. **Jump to method **. If you are pressing `Ctrl + F` to find a method inside of your code, you are doing it wrong. Most IDEs and even text editors, such as Atom (with the proper language server / support) can jump straight there. For example, in Atom, you can do this with `Ctrl + R` (at least on Linux) There are numerous advantages

   * The search is often fuzzy, so you only need to recall a few characters
   * You can see all the symbols in one view, so you can flip through them fast if you need to often
   * You can get there by just typing some characters instead of scrolling and then positioning the cursor
   * You only get **definitions** and not all the usages as well and then need to read each result you get if you were to have done a search

   ​

2. **Go to file / class**. This is also a big one that I see a lot of people use already and it is rare that I do not see someone use it. Hunting for a single class or file in your structure is painful and could require dozens of seconds to get right, depending on how large your project is. `Ctrl + Shift + F` is not the right answer ==  instead, use something like `Ctrl + P` in Atom or `Ctrl + O` in Jetbrains IDEs. ... and now you get something that can help you find a file very quickly.

3. **If your tooling supports it, learn your quick navigation tools such as "Go to class" or "Go to definition" when you have a word selected.** Visual Studio Code has good support for this.
{'fraction_non_alphanumeric': 0.04339622641509434, 'fraction_numerical': 0.0014824797843665768, 'mean_word_length': 3.8250975292587777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3867777', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1735, 'n_words': 1322}