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

Temporary Refactoring and Improving Your Code Reading Skills

DZone's Guide to

Temporary Refactoring and Improving Your Code Reading Skills

A developer discusses technique he learned from a colleague in which he temporarily refactors code in order to better understand what another dev has done.

Free Resource

See how three solutions work together to help your teams have the tools they need to deliver quality software quickly. Brought to you in partnership with CA Technologies

I was talking to a friend of mine, Scott, over Slack about reading code! Specifically, how to improve your code reading skills.

I asked him what he usually does when he reads source code. What he said is interesting:

He does a temporary refactoring. That’s it.

He usually takes a long method that can be separated out and then he turns it into a separate method.

For example-  readEmployeeDataFromDatabase()

This method can be broken into multiple methods and he does that. He keeps doing that until he gets a sense for what the intent of the larger method is about. Then he takes a few notes on what the method does and rolls back the changes.

He also mentioned that he does not do any unit testing because this refactoring is only temporary, and used just to understand the code!

I believe this could be a great way towards improving code reading skills. Although what he suggested isn’t really true refactoring, it can help you to understand the code you are reading.

Discover how TDM Is Essential To Achieving Quality At Speed For Agile, DevOps, And Continuous Delivery. Brought to you in partnership with CA Technologies

Topics:
refactoring ,agile ,readable code ,learning and development

Published at DZone with permission of A. N. M. Bazlur Rahman, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}