Did you know that Real Studio has a bunch of refactoring features that can help make you more efficient? Let's take a look at them.
Classes
When you access the contextual menu of a class (right-click or control-click on OS X), you'll see these two features in the menu: New Subclass and Extract Superclass.
New Subclass
Click on New Subclass and Real Studio creates a new class in your project that automatically has the selected class set as its Super.
Extract Superclass
The Extract Superclass feature opens a dialog that lets you choose the methods and properties to extract from the selected class and move to a superclass. The selected class also gets its Super set to the newly created super class.
 |
Extract Superclass Dialog |
Methods
With the Code Editor open, you can see refactoring features when you view the contextual menu for methods and properties.
With a regular method selected, you will see Convert to Shared. This feature converts the method from a regular method (an instance method) to a shared method. If you were to right-click on a shared method then you would instead see Convert to Regular which does the opposite.
Properties have a similar feature to Convert to Shared or Convert to Regular. In addition they have Convert to Computed Property. This feature will take your current regular property, rename it with an "m" at the beginning, make it private and then make a public computed property that uses the regular property as its back end storage for the Get and Set components.
Code Editor
When you are editing code, the contextual menu has several useful refactoring features.
Wrap in If/End If
This takes either the current line of code or the current selection and wraps it in an If..Then/End If block.
Wrap in Do/Loop
As above, but wraps it in an Do..Loop block.
Wrap in While/Wend
As expected, wraps it in a While..Wend block.
Convert to Method
This feature takes the current selection and moves it to a method for you and then takes you to the method where you can specify the name and parameters. Don't forget to go back to the original code and add the method call, though!
Convert to Constant
Takes the selected text and moves it to a constant definition. The name of the constant is the name of the selected text. Real Studio replaces the selected text with the newly created constant name. This is very handy for localizing as it makes is quick and easy for you to move hard-coded strings to constants.
Define Missing Method
When I write my code, I often will type a method name that I expect to use even though it doesn't actually exist yet. I can then go back, select the method name and choose Define Missing Method to have Real Studio create the method definition for me. In order for this option to be enabled, you do have to select a method that has parenthesis even if there are no arguments. So Calculate() works but just Calculate does not.
Standardize Format
This is my favorite feature. I use this all the time. It takes the selected block of code and applies consistent formatting to it. There is nothing that I hate more than source code that has inconsistent naming.
Inconsistent capitalization drives me nuts:
dim i as Integer
It should be:
Dim i As Integer
or at the very least this, even though I don't like all lowercase:
dim i as integer
Standardize Format keeps me sane!
 |
Properly Formatted Code |
I hope one of these features will help make your development more efficient!