A common problem for developers is being able to work effectively with and understand large code bases. This problem can affect everyone on a team, whether youâ€™re new or experienced. Itâ€™s hard to know every line, and everyone needs to find their way around the code base.
Better not refactor!
OrionÂ to the rescue
Imagine that youâ€™re browsing a code base and you see a function call. You might ask yourself:
â€œWhere is this function defined? Are there multiple declarations? Who else uses this thing? If I change the implementation, who is affected?â€
Fortunately, OrionÂ has a new feature to help in this scenario. Itâ€™s called â€œReferences.â€ To use it, click a code element, such as a function call, and select an option from the References menu:
A window opens to show each match, categorized and weighted:
OrionÂ includes a type-inference engine that can determine the type and scope of a function or variable. This information is used to weigh the results.
Here is a handy legend:
- Green check mark: Perfect match
- Blue question mark (?): Potential match
- Red (x): Not a match
Go ahead and refactor
You can refactor the references that you found to the main() function to be main2() by clicking Preview:
A simple rename consists of these actions:
- Finding all of the references
- Inspecting each reference by category, noting any checks and question marks
- Selecting or clearing the replacement check box
- Clicking Replace
Of course, refactoring is more than renaming, but the first step is to find and categorize each match.
You can use the new References feature in OrionÂ to understand how a variable or function is being used. Understanding the code is the first necessary step towards refactoring.