How to use code refactoring in DVT?

This document shows how to use the Refactoring option in DVT in order to rename variables/classes/interfaces, and how to simply extract part of the code to a function.

#1 Renaming variables/classes/interfaces etc.

If you right-click on something you want to rename you can go to:

Refactor -> Rename  (or remember the shortcut Shift+Alt+R)

After that, a new window will pop up where you can change the name:

You can preview all the changes in all files, and double check if it’s necessary,and turn it off where you don’t need the change, etc. DVT will automatically rename each instance of the specific variable across all files. It can recognize instances of specific variables and change it everywhere. If something is ambiguous and DVT is not sure how to handle it,you will need to preview the changes.

#2 Extracting code to a function

First you need to select the code you want to move to a function:

Right click -> Refactor -> Extract to Function

DVT will generate the function for you and call it in the right place.

If you right-click the function name you can go to:

Refactor -> Split to Extern and Implementation

And DVT will generate the code for you:

After all this you can use the Refactor -> Rename to change the name of the function from extracted() to a proper name or simply use Find/Replace.

Contact Us

Please, enter your details below. We will get back to you as fast as we can.

This website uses cookies to ensure you get the best experience on our website.

Get Cogita

Please, enter your details below. We will get back to you as fast as we can.

Thank you!

We will get in touch soon.

Get a Quote

Please, enter your details below. We will get back to you as fast as we can.