Code Template in JustCode

Code Templates are reusable code snippets. Telerik Just Code helps to create reusable code templates for better developer productivity.

You can Free Trial of Telerik Just Code from here

There are three groups of Code Templates available

  1. Iteration
  2. Surrounding
  3. Conditional or basic statements

To insert code template you need to press ALT+END . You will get below popup

clip_image001

From popup you can choose code template to insert. If you are choosing

clip_image003

Now pressing tab will give you next variables to choose. In this way you can insert any code template by choosing it from popup.

You can insert a snippet using their acronym also. After the acronym press Shift+Space to insert code template.

You can also define your own code template. To create a code template click on JustCode->Option->CodeTemplate option from menu. Then click Add to add a new Code Template.

clip_image005

Basic syntax to create a template is as below,

$number[=function]$

Number is any natural number and function is any existing template function. If you want to create a basic template for If statement you can create it as below. I am giving acronym name as DJ.

clip_image007

In code after typing DJ when I press Shift and Space I get below code generated

clip_image008

In this way you can work with Code Template using Telerik Just Code. I hope this post is useful. Thanks for reading

 

Refactoring using JustCode

In this post we will see Refactoring techniques using Telerik JustCode. Telerik Just Code helps to perform following refactor operation.

You can perform many refactoring using Teleirk Just Code. Few of the refactoring can be performed are as below,

  • Convert Abstract class to Interface
  • Convert Interface to Abstract class
  • Convert Anonymous method to Lambda
  • Convert Anonymous method to Named Method
  • Convert Class selector to ID selector in CSS
  • Convert ID selector to Class selector in CSS
  • Convert Constructor to Factory method
  • Convert Extension method to Static method
  • Convert Method to Property
  • Convert Lambda to Named Method
  • Convert Lambda to Anonymous method and many more

Let us see few of the refactoring; we can perform using Telerik JustCode

Convert Abstract class to Interface

Let us s you have abstract class as below,

image

This class can be refactored to interface using Telerik Just Code.

  • Select class and press Alt+Insert
  • Choose R option
  • From R option choose convert to Interface

image

After converting resultant interface would be as below,

image

Convert Anonymous method to Lambda Expression

I have created a delegate as below,

image

And using delegate with anonymous function as below,

image

Above anonymous function can be converted to Lambda Expression as below,

  • Select anonymous function and press Alt+Insert
  • Choose R option
  • From R option choose convert to Interface

image

Resultant lambda expression would be as below,

image

Convert Anonymous method to Named Method

If you want to convert above anonymous method to named method, you can very much do that as below,

  • Select anonymous function and press Alt+Insert
  • Choose R option
  • From R option choose To Named Method

image

Resultant named method would be as below,

image

Convert Constructor to Factor Method

I have a class with constructor as below,

image

If you want to convert constructor to factory method, you can do that as below,

  • Select constructor and press Alt+Insert
  • Choose R option
  • From R option choose Convert Constructor to Factor method

image

Resultant factor method would be as below,

image

In similar way you can perform other refactoring operations using Telerik Just Code. I hope this post is useful. Thanks for reading

Code analysis using JustCode

Read Error Inspection using Telerik JustCode here

JustCode do on the fly analysis of the code. It does code analysis when you type the code and reports you and error or warning without any further delay.

image

You can download Telerik JustCode 60 days-trial version with dedicated support here

To have high lever perspective on Telerik JustCode, I have just console application and put no code so far.

image

JustCode does the analysis along with the visual studio inspection. It performs analysis using some custom inspection.

On the fly you can fix any error reported by pressing Alt+Enter. For example below Method2 is trying to pass parameter to Method1 whereas Method1 is defines without any input parameter. At the time of calling of Method1, on pressing Alt+Enter ,JustCode will suggest you the possible fixes.

image

JustCode performs below inspection on the Code,

For C#

  • Identical if and else clauses
  • Obsolete casts
  • Empty statements
  • Assignments with no effect
  • Unused private members
  • Unused parameters
  • Unused variables
  • Unused namespaces
  • Unreachable statements

For XAML

  • Missing object element type
  • Missing type of an attached property
  • Missing property that an attached property is referring to
  • Not found event handlers
  • Ambiguous property that an attached property is referring to

By default JustCode reports error in color red and warning in green.

Error in Red

clip_image002

If you want to change default color of reporting you can do it by navigating to

Tools->Options->Environment

clip_image004

I have changed error reporting color to blue and now error is reported in blue color as below,

clip_image006

Inspection of the code can be done in fours ways

Via a tooltip over a highlighted expression

clip_image001

Via a info popup

clip_image002

Via a tooltip in the Marker Bar

clip_image003

In the Error list Window

clip_image004

In this way you can perform analysis of code and fixing of any error reported using Telerik JustCode. I hope this post is useful. Thanks for reading

Code Navigation and Search with JustCode

Simply I cannot work without Telerik Just Code .It boost my productivity to next level. In this post, I am going to discuss on Code Navigation and Search feature of this amazing product. You may want to have a look on my previous post Error Inspection using Telerik Just Code

Advantages

  • Quickly navigate to different parts of code
  • Easily find definitions, errors, types, members etc.
  • Easily highlight found errors, types, members etc.
  • Quick navigation via Find Result Windows.
  • Camel case search : This searches capital letters of compound names

Go To options

There are four Go To Options available

clip_image002

clip_image003

In my sample console application I have created a class called Product. If I want to search that type (class in this case) then I can search like below,

clip_image004

Search Windows gives you information that class is internal class and its namespace name. if you press enter you will navigate to class definition.

Find Usage is another powerful feature . This can boost up productivity. This helps to navigate and search to different

  • Classes
  • Namespaces
  • Local variables
  • Methods
  • Fields

clip_image005

In Find Result windows you can see the usage of definitions or keywords. All different usage term would be open in different tabs. In below case type product and namespace usage is open.

clip_image006

In this way you can explore many other navigate options given by Telerik Just code option. I am very looking forward to explore more features of this amazing product. I will share my learning on the sameĀ  Smile