Welcome Guest.   Make a donation to an author on the site November 24, 2014, 11:50:34 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Your Support Funds this Site: View the Supporter Yearbook.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: What in the world is "Refactoring?"  (Read 1474 times)
CodeTRUCKER
Supporting Member
**
Posts: 1,028



Bush Flying... where I'd rather be.

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« on: January 03, 2011, 04:35:24 PM »

What is Refactoring?

Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior. Its heart is a series of small behavior preserving transformations. Each transformation (called a 'refactoring') does little, but a sequence of transformations can produce a significant restructuring. Since each refactoring is small, it's less likely to go wrong. The system is also kept fully working after each small refactoring, reducing the chances that a system can get seriously broken during the restructuring.


FYI - the whole paragraph abve is a link to "www.refactoring.com".

Ok, I read this.  Can someone please translate it into something I can tell my children (and I can understand)?
Logged

I applaud those that refuse to commit "intellectual suicide."

Truth, unlike opinion, tradition, etc. will always be able to stand on its own.  Truth is not a static, but a living entity and will perpetually impart life; therefore, any "truth" that does not or can not impart life can not be Truth.

I am persuaded the only reason bad men have succeeded is not because good men have done nothing, but that good men did not do enough.

An Open Letter to My Friends


Notice: - Unless stated otherwise, I receive no compensation for anything I post here.
Stephen66515
Animated Giffer in Chief
Honorary Member
**
Posts: 2,778



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #1 on: January 03, 2011, 04:39:19 PM »

simply put

whole new code, for the same results.

kind of like this:

in HTML will give you bold text

now, if you was to change that to BBCode (the stuff you use here)

would give you bold text.

Different internal code, same external results.

It could get more technical, but its along those lines smiley
Logged

No trees were harmed during the creation of this message.  Millions of electrons, however, were terribly inconvenienced

"Think left and think right and think low and think high. Oh, the things you can think up if only you try!" - Dr. Seuss
mouser
First Author
Administrator
*****
Posts: 33,692



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: January 03, 2011, 04:40:32 PM »

whoever wrote that is trying too hard to make something sound complicated, kind of like people try to do when they are writing their resume and want to make their job sound important.

When people talk about "refactoring" their code, what they really mean is going back into the code and improving the way it is written (typically without adding functionality).

In other words, it's when you take the time to reorganize your code and use better data structures, and make it work better, and usually make the code cleaner and more stable.
Logged
CodeTRUCKER
Supporting Member
**
Posts: 1,028



Bush Flying... where I'd rather be.

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: January 03, 2011, 04:43:30 PM »

Ok, so when an language/IDE advertises it has "excellent refactoring" it is saying that it will rewrite the code I input to make a more concise programming verbiage?
Logged

I applaud those that refuse to commit "intellectual suicide."

Truth, unlike opinion, tradition, etc. will always be able to stand on its own.  Truth is not a static, but a living entity and will perpetually impart life; therefore, any "truth" that does not or can not impart life can not be Truth.

I am persuaded the only reason bad men have succeeded is not because good men have done nothing, but that good men did not do enough.

An Open Letter to My Friends


Notice: - Unless stated otherwise, I receive no compensation for anything I post here.
worstje
Honorary Member
**
Posts: 555



The Gent with the White Hat

View Profile Give some DonationCredits to this forum member
« Reply #4 on: January 03, 2011, 04:47:37 PM »

I think mouser gave a good description of refactoring. However, as an example, think of a function that does a ton of things: get the data from a website, loops over the characters, tries to extract content, perform calculations, etc. Think of a monster that's multiple screenfuls in length.

Such functions can pretty much always be rewritten to be more understandable. How? By splitting it up into smaller pieces that take care of those other pieces. As a bonus, if you need said functionality in the future, you won't be tempted to copy paste, but can use a simple function-call to the same effect... except any bugs only need to be fixed in a single location. So rather than multiple screenfuls, you'll end up with several smaller functions that (as a general idea) fit on a single screen, easily understandable. And the big monster you had before that suddenly fits on a single screen too (again, as a general idea) with all the different tasks explaining themselves (content = GetWebpage(), number = SearchContentForNumber(content), number += 5)...

Of course, that is a bit too simplified, but that is what it in my experience comes down to.

And regarding 'excellent refactoring' in IDEs... it more-so comes down to for example selecting a few paragraphs of code, and immediately putting it in another function with proper parameters, or other often-used tasks to improve code health.
Logged
mouser
First Author
Administrator
*****
Posts: 33,692



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #5 on: January 03, 2011, 04:49:16 PM »

when an IDE says it has "Refactoring" tools, it means it has a bunch of separate small little ways it can help you refactor/modify your code, like worstje said.  these may range from simple things like renaming functions, adding arguements to functions, splitting up functions, etc.
Logged
CodeTRUCKER
Supporting Member
**
Posts: 1,028



Bush Flying... where I'd rather be.

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #6 on: January 03, 2011, 04:55:50 PM »

when an IDE says it has "Refactoring" tools, it means it has a bunch of separate small little ways it can help you refactor/modify your code, like worstje said.  these may range from simple things like renaming functions, adding arguements to functions, splitting up functions, etc.

@mouser and worstje
In y'alls (I'm from Texas) collective experience, are these "refactoring tools" a real valid and usable bonus or just marketing hype, smoke and mirrors, etc.?
Logged

I applaud those that refuse to commit "intellectual suicide."

Truth, unlike opinion, tradition, etc. will always be able to stand on its own.  Truth is not a static, but a living entity and will perpetually impart life; therefore, any "truth" that does not or can not impart life can not be Truth.

I am persuaded the only reason bad men have succeeded is not because good men have done nothing, but that good men did not do enough.

An Open Letter to My Friends


Notice: - Unless stated otherwise, I receive no compensation for anything I post here.
mouser
First Author
Administrator
*****
Posts: 33,692



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #7 on: January 03, 2011, 05:00:24 PM »

it really depends on what kind of coder you are and how well you take to these new fangled IDE fancy tools.

if you're anything like me, it's too late for your brain to really make good use of them.  when my code needs to be improved i do it by hand or with dead simple search and replace stuff.  i've just never really learned to make use of refactoring tools and don't see myself doing so.
Logged
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #8 on: January 03, 2011, 05:00:31 PM »

An explanation of "refactoring" can be boiled down to: "cleaning up source code".

Refactoring.com is apparently Fowler's, he's the guy behind the "original refactoring book". One of the ideas of that book is that you don't "just" clean up code - you clean it up as a series of small, well-defined and named tasks... and run your code tests after each task.

It's those individual tasks that a good IDE with refactoring support can do; it still needs your "architect" brain to direct the bigger picture.
Logged

- carpe noctem
CodeTRUCKER
Supporting Member
**
Posts: 1,028



Bush Flying... where I'd rather be.

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #9 on: January 03, 2011, 05:05:33 PM »

...
It's those individual tasks that a good IDE with refactoring support can do; it still needs your "architect" brain to direct the bigger picture.

Thanks to you,worstje and mouser for the simple definitions.  I did kind of figure it wasn't a "check your brain at the door" kind of thing.  The variables for those variables would be far too variable. tongue
« Last Edit: January 03, 2011, 05:10:39 PM by CodeTRUCKER » Logged

I applaud those that refuse to commit "intellectual suicide."

Truth, unlike opinion, tradition, etc. will always be able to stand on its own.  Truth is not a static, but a living entity and will perpetually impart life; therefore, any "truth" that does not or can not impart life can not be Truth.

I am persuaded the only reason bad men have succeeded is not because good men have done nothing, but that good men did not do enough.

An Open Letter to My Friends


Notice: - Unless stated otherwise, I receive no compensation for anything I post here.
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #10 on: January 03, 2011, 05:06:21 PM »

i've just never really learned to make use of refactoring tools and don't see myself doing so.
That's a pity, since some of it is really boring manual work. Especially in the C#/.NET land, ReSharper is pretty darn awesome. Whole Tomato's Visual Assist is pretty good for C++. Dunno what offers there are for BCB...

But it's definitely nice working with refactoring support that's well integrated in your IDE. Trying to, say, rename stuff across a whole project definitely isn't fun without it.
Logged

- carpe noctem
CodeTRUCKER
Supporting Member
**
Posts: 1,028



Bush Flying... where I'd rather be.

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #11 on: January 03, 2011, 05:09:16 PM »

it really depends on what kind of coder you are and how well you take to these new fangled IDE fancy tools.

if you're anything like me, it's too late for your brain to really make good use of them.  when my code needs to be improved i do it by hand or with dead simple search and replace stuff.  i've just never really learned to make use of refactoring tools and don't see myself doing so.


Oops... missed this!

Unfortunately, I have forgotten more than I will ever learn from here on out.  I wish I could be refactored.  Sad
Logged

I applaud those that refuse to commit "intellectual suicide."

Truth, unlike opinion, tradition, etc. will always be able to stand on its own.  Truth is not a static, but a living entity and will perpetually impart life; therefore, any "truth" that does not or can not impart life can not be Truth.

I am persuaded the only reason bad men have succeeded is not because good men have done nothing, but that good men did not do enough.

An Open Letter to My Friends


Notice: - Unless stated otherwise, I receive no compensation for anything I post here.
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.035s | Server load: 0.15 ]