Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Complex Refactoring in Simple Steps: Part I

DZone's Guide to

Complex Refactoring in Simple Steps: Part I

In this series we examine how to refactor complex code. In this installment, we take a look a method that exhibits the Long Parameter List and Data Clump smells. What can be done?

· Agile Zone ·
Free Resource

Adopting a DevOps practice starts with understanding where you are in the implementation journey. Download the DevOps Transformation Roadmap. Brought to you in partnership with Techtown.

Matthew Butt demonstrates how to compose simple automated refactoring steps in ReSharper to refactor code to better designs.

In this episode, we look at a method that exhibits the  Long Parameter List and  Data Clump smells. We  Extract Class from Parameters to create a parameter object, and then, spotting  Feature Envy, use  Move Instance Method to shift the behavior to the new class. We finish by tidying up the method object to remove generated code that might tempt us to break encapsulation.

The code used in this video can be found on GitHub.

This article was first published on the Codurance blog.

Take Agile to the next level with DevOps. Learn practical tools and techniques in the three-day DevOps Implementation Boot Camp. Brought to you in partnership with Techtown.

Topics:
simple ,better ,automated ,refactoring ,parameter ,list ,designs ,programming

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}