Navigating Code

As you program, you will have questions about the classes you're working with. Learning how to browse the code and locate the answers will accelerate your work.

Current files

When you open a file in your editor, it adds a tab to let you navigate to currently open files. Most developers start off by clicking the tabs to move between their code.

You can navigate through these files in different ways.

Jump to the previously open tab with ctrl + tab. Type it again and it will come back to the file you were just on. If you hold ctrl and press tab two ore more times, it will go backwards through your history to get that tab. You should see a list of open files when you hold ctrl, press tab and keep holding ctrl.

This is a fairly universal command and should work in your browser tool. Alt + tab will switch between applications. I use these two a lot while coding.

Read the interface files

You will often see this function comment:

/**
 * {@inheritdoc}
 */

This is saying that the function is implementing something defined by it's parent or an interface file.

An interface file has all the function comments, but none of the logic. They're used to define a reusable set of functions that a class can implement to use the interface. They give a good high level overview of the object's capabilities.

Code Structure Outline

Many IDEs can show you an outline of the current file. This screenshot has constants at the top, and hook functions implemented in system.module.

Drupal system module outline

When editing a class, you can see functions that it inherits. This tells you what functions you can use in your code.

Level
Topics