Over a million developers have joined DZone.

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

Learn more about how DevOps teams must adopt a more agile development process, working in parallel instead of waiting on other teams to finish their components or for resources to become available, brought to you in partnership with CA Technologies.

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.

Discover the warning signs of DevOps Dysfunction and learn how to get back on the right track, brought to you in partnership with CA Technologies.


Published at DZone with permission of Matthew Butt, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}