Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Code refactoring

 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is code refactoring?
Is there something called as "code factoring". If yes how does it differ from code refactoring.
Thanks in advance.
Pradeep
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The term "code factoring" (and thus also "refactoring") is based on the mathematical notion of factoring, an algebra technique.
Consider the simple mathematical equation:
a = 2 b + 2 c
I guess most of us would understand that it can also be represented as
a = 2 ( b + c )
The process of separating out the multiplication by 2 from the addition is commonly known in algebra as "factoring". In general, a simpler and/or smaller equation or expression is considered to be a better one.
Likewise in the design of software.
Some software theorists (notably Charles "Chuck" Moore the inventor of the FORTH language) use the term "factoring" and "well factored" to mean designing software in a way where there is as little duplication as possible.
Others accept that the initial design of
anything will probably be less than perfect, so use the term "refactoring" to mean adjusting the software in a way that preserves its behaviour and meaning, but improves the way it is designed (typically by addressing and removing duplication).
 
Marshal
Posts: 16631
278
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excellent explanation, Frank.
Martin Fowler wrote the book on Refactoring.
 
Pradeep bhatt
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does code factoring and refactoring mean the same thing.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pradeep Bhat:
Does code factoring and refactoring mean the same thing.


Refactoring is when you do a new factoring, probably since something has changed since you did the initial factoring.
According to the above example you coul factor the statement:
a = 2 b + 2 c
so it becomes:
a = 2 ( b + c )
But what if the statement is later changed and an extra term ( 2 d )is added, like this:
a = 2 ( b + c ) + 2 d
this statement could then be refactored to:
a = 2 ( b + c + d )
I guess that refactoring could be seen as a repeated factoring and that they are quite the same.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic