resharper

21
Resharper Refactoring and productivity extension by JetBrains

Upload: hanoh-aloni

Post on 05-Apr-2017

690 views

Category:

Engineering


4 download

TRANSCRIPT

Page 1: Resharper

Resharper

Refactoring and productivity extension by JetBrains

Page 2: Resharper

Refactoring

“A disciplined technique for restructuring an existing body of code, altering its internal

structure without changing its external behavior"

Abstraction Class fragmentation

Naming convention

Page 3: Resharper

Refactoring - Abstraction

• Techniques that allow for more abstraction– Encapsulate Field – force code to access the field

with getter and setter methods– Generalize Type – create more general types to

allow for more code sharing– Replace Type– Replace conditional with polymorphism

Page 4: Resharper

Refactoring - Class fragmentation

• Techniques for breaking code apart into more logical pieces – Componentization breaks code down into reusable

semantic units which present clear, well-defined, simple-to-use interfaces.

– Extract Class moves part of the code from an existing class into a new class.

– Extract Method, to turn part of a larger method into a new method. By breaking down code in smaller pieces, it is more easily understandable. This is also applicable to functions.

Page 5: Resharper

Refactoring - Naming convention

• Techniques for improving names and location of code – Move Method or Move Field – move to a more

appropriate Class or source file– Rename Method or Rename Field – changing the

name into a new one that better reveals its purpose

– Pull Up – in OOP, move to a superclass– Push Down – in OOP, move to a subclass

Page 6: Resharper

Features

• Code browsing• Code clean-up• Refactoring• Coding assistance• Micro code generation• Other useful features

Page 7: Resharper

Support

• C# 5.0• VB11• JavaScript• CSS• HTML• ASP.NET • ASP.NET MVC

• Razor• XML, XAML• WinRT• MSBuild and NAnt

build scripts.

Page 8: Resharper
Page 9: Resharper

IDEA vs VS

• 2 different keyboard scheme– IDEA more familiar to Intellij IDE– VS scheme more familiar to VS users– VS scheme will never override a key mapped by

visual studio

Page 10: Resharper

Part 1 : Code browsing

• Navigate : ART-R-N Find : ALT-R-F• Navigate to : Alt-' File : ctrl-t / ctrl-shft-t / alt-

shift-t • Related files : ctrl - alt - f7• Goto implementation : ctrl-F12• Goto definition : alt-F12 • Find usages : shift f12

Page 11: Resharper

Part 2 : Code clean-up

• quickfix trio : – Alt-Enter – Alt-PgDn – Alt-PgUp

• moving code around: ctrl-alt-shift-arrows • View file structure: ctrl-alt-f • Code cleanup: ctrl-e-c • see: resharper -> options -> c# -> formatting style • Safe delete : alt-Del

Page 12: Resharper

Part 3 : Refactoring

• Convert• Rename• Change signature• Encapsulate/extract fields/properties/classes• Introduce field/method/variable• Inline field/method/variable• Move to folder• Pull and push memebers

Page 13: Resharper

Part 4 : Coding assistance

• Code generation• Code templates• Code cleanup

Page 14: Resharper

Part 5 : Micro code generation

• Snippets• Generators• Templates

Page 15: Resharper

Part 6 - other

• Stack trace explorer• goto decleration to decompiled MSIL• TODO list explorer• Test runner • Globalization • Patterns catalog • XML document support• MSBuild or nant build scripts support• Javascript and CSS support

Page 16: Resharper

Pros and cons

• Helps enforce standards• Boosts productivity• Helps code reviews• Good analysis tools

• Over-refactoring• Tool reliance• Shapes the way you

think

Page 17: Resharper

Learning tips

• Keep the keymap under your keyboard• Focus on a few commands at a time• Don’t be afraid to try new shortcuts• Keep your hands on the keyboard• Watch other people use Resharper• Learn with friends and teammates

Page 18: Resharper

The end

Page 19: Resharper

Extra

Page 20: Resharper

What does it do?

• solution-wide static code analysis (error detection on-the-fly, without the need to compile)

• provides additional features for error correction• code completion, navigation, search• syntax highlighting, formatting• code generation and optimization • carries out 40 automated refactorings and

streamlines unit testing using NUnit and MSTest