Monday, January 4, 2016

Refactoring in Swift

Definition

Refactoring is the activity of cleaning the code, improving the design, after the code is written.

Refactoring is not changing the functionality of the code. If it does, it is called maintenance. [Thank you Max]

You can say that it is corresponding to the design phase, but after some piece of code was written.

While a developer can plan for the code to be nicely written, in time, the code gets messier so cleaning is required.

Just like the house cleaning, the more often the code is cleaned, the easier and more effective it is.

Refactoring does not bring any benefit right away. The functionality is not changed during this activity so there is no change for the user. The real benefit is when new features are added.

We’ll start today a series of refactoring tips in Swift, most of them adapted/stolen from Martin Fowler’s “Refactoring - Improving the design of existing code” book.

2 comments:

  1. Hi Dragos,

    I think you should mention that the primary goal of re-factoring is to improve the code structure without changing the code behaviour. If you're changing the code behaviour, that's called maintenance.

    ReplyDelete