Indy.Code() Sessions tagged code craftsmanship

Refactoring - Saving Your Code From Yourself

Abstract

Writing code that does what you want it to is easy. Writing code that is easy to understand is harder. Fortunately, you are not doomed to code that no one can understand or maintain if you know how to refactor it.

Description

Refactoring is a useful but often poorly understood skill. Effective refactoring leads to code that is easier to understand, maintain, and test. In this talk, you will learn how to identify code that needs to be refactored, types of refactoring you can do, and how to verify you’ve improved your code using Code Metrics tools in Visual Studio.

Signs you need to refactor:

  • Overly long methods
  • Unclear variable and method names
  • Too many input parameters
  • Unrelated code in the same method
  • Duplicated code
  • Lots of loops

Types of refactoring:

  • Rename refactoring
  • Method extraction
  • Consolidating code

Verifying improvement with Code Metrics:

  • Maintainability (should be high)
  • Complexity (should be low)

Speaker

Lorien Rensing

Lorien Rensing

Software Developer III, Making Everlasting Memories

A Physics of Software Design

Learning how to write quality, maintainable code has been a question left to intuition, personal reinvention (after repeated failure), and the memorization of maxims such as "Tell Don't Ask", "Feature Envy", SOLID, et al.

But can we compare these maxims – these learned lessons – across paradigms, and arrive at a generalization which serves as a sort of guiding "Grand Unified Theory of Software Development" (Jim Weirich)?

Some of this work has been done, and the resulting concept and vocabulary is not only simple to explain (and immediately applicable) to early learners, but can serve as a metric for quantifying maintainability and refactoring opportunities at all levels of software architecture.

Speaker

David Michael Gregg

David Michael Gregg

Instructor, Software Engineering, Kenzie Academy