Skip to main content

The Difference Between Refactoring and Changing

The word refactoring has become popular in software development. Unfortunately, like many things in software development, not everybody uses it right. That is probably because it takes some effort to understand.

Somebody who doesn't understand refactoring might use the words "refactor" and "change" interchangeably, like synonyms. However, refactoring does not mean the same thing as changing.

Example Using Math
Refactoring means changing the factors without changing the result. Refactoring software is like refactoring a multiplication problem in arithmetic. For example, consider the math problem:
  • 3 * 4
This can be refactored to:
  • 2 * 2 * 3
  • 2 * 6
In these examples, the factors change, but the result remains the same:
  • 3 * 4 = 12
  • 2 * 2 * 3 = 12
  • 2 * 6 = 12
However, making this kind of change is not refactoring:
  • 3 + 4
Because it changes the result:
  • 3 * 4 = 12
  • 3 + 4 = 7
So, that was a different kind of change.
Refactoring does not mean the same thing as changing.
Example in Software
Refactoring software has a similar meaning to refactoring math problems. Refactoring refers to a specific kind of change which changes the implementation of the software without changing the application of the software. In other words, refactoring involves changing the inner workings of software "under the hood" without changing its external functionality.
Refactoring means changing the factors without changing the result.
For example, consider a program like this:
  • Declare a new variable named "greeting"
  • Initialize the value of greeting to "Hello World!"
  • Display the value of greeting
This can (and probably should) be refactored to:
  • Display the value "Hello World!"
That change was refactoring because the refactored program does exactly the same thing. They both display "Hello World!" The refactored version simply no longer uses a named variable to do it. Therefore, it is a shorter, simpler, and higher quality program.

However, this kind of change would not be refactoring:
  • Display the value "Hello Sailor!"
That change affects more than the inner workings of the program, because it changes what the program actually does. The program's external functionality now displays a different message.

Accurately understanding what refactoring is and how it works provides a very useful tool to improve the quality of your software development.

Popular posts from this blog

What We're About

About UsMission Statement: We provide a product to make high performing software developers happy by giving them a chance to work in a more self-directed way on software that is more meaningful to them. Core Values (in priority order):Integrity: Honesty, trustworthiness, and faithfulnessPreparation: Research, planning, and goalsReputation: Branding, naming, presence, and networkingProfitability: Product salesProduction: Product development, ideas, online contentImprovement: Research and trainingSupport: Minimal overhead Who We Are
Isaac Serafino is a Software Architect in Omaha, Nebraska. He has a strong experience developing technology solutions. He has long had the dream to lead his own startup business.
Our ProductsSnap Screen™
More efficiently provide a safe environment for using electronic devices. Sends pictures of what is on the display at somewhat random times so user knows they could be observed at any time, but the supervisor does not need to be their watching over their sho…

The Invasion of the Developer Commandos™

I. Why Deploy Commandos? It's hard to find the best people to solve difficult problems. By deploying Developer Commandos™, you can get great software developed without needing to figure out how to find the software developers. II. What are Developer Commandos? Unlike an old fashioned developer, a commando works independently. They manage themselves so you won't need to. III. How Can You Deploy Commandos? A. Create a Project Use a project host like GitHub to create a shared workspace online. Commandos will be able to contribute to your software project through this workspace. B. Obtain Incentives Use a cryptocurrency exchange like Coinbase to purchase an amount of a cryptocurrency such as Ether. You will be able to use this cryptocurrency to provide an incentive for commandos. C. Post Opportunities Use a bounty network such as Gitcoin to post bounties. A bounty describes the software problem you need resolved, and allows you to attach a cryptocurrency incentive for resolving i…