2. 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
3. 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
4. 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.
5. 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
6. Features
• Code browsing
• Code clean-up
• Refactoring
• Coding assistance
• Micro code generation
• Other useful features
7. Support
• C# 5.0
• VB11
• JavaScript
• CSS
• HTML
• ASP.NET
• ASP.NET MVC
• Razor
• XML, XAML
• WinRT
• MSBuild and NAnt
build scripts.
8.
9. 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
15. 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
16. Pros and cons
• Helps enforce standards
• Boosts productivity
• Helps code reviews
• Good analysis tools
• Over-refactoring
• Tool reliance
• Shapes the way you
think
17. 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
20. 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