topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 6:25 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: What in the world is "Refactoring?"  (Read 4525 times)


KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,741
    • View Profile
    • Donate to Member
Re: What in the world is "Refactoring?"
« Reply #1 on: January 03, 2011, 04:39 PM »
simply put

whole new code, for the same results.

kind of like this:

<b>
in HTML will give you bold text

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

[b]
would give you bold text.

Different internal code, same external results.

It could get more technical, but its along those lines :)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: What in the world is "Refactoring?"
« Reply #2 on: January 03, 2011, 04:40 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.

CodeTRUCKER

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,085
    • View Profile
    • Donate to Member
Re: What in the world is "Refactoring?"
« Reply #3 on: January 03, 2011, 04:43 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?

worstje

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 588
  • The Gent with the White Hat
    • View Profile
    • Donate to Member
Re: What in the world is "Refactoring?"
« Reply #4 on: January 03, 2011, 04:47 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.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: What in the world is "Refactoring?"
« Reply #5 on: January 03, 2011, 04:49 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.

CodeTRUCKER

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,085
    • View Profile
    • Donate to Member
Re: What in the world is "Refactoring?"
« Reply #6 on: January 03, 2011, 04:55 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.?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: What in the world is "Refactoring?"
« Reply #7 on: January 03, 2011, 05:00 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.

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: What in the world is "Refactoring?"
« Reply #8 on: January 03, 2011, 05:00 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.
- carpe noctem

CodeTRUCKER

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,085
    • View Profile
    • Donate to Member
Re: What in the world is "Refactoring?"
« Reply #9 on: January 03, 2011, 05:05 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. :P
« Last Edit: January 03, 2011, 05:10 PM by CodeTRUCKER »

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: What in the world is "Refactoring?"
« Reply #10 on: January 03, 2011, 05:06 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.
- carpe noctem

CodeTRUCKER

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,085
    • View Profile
    • Donate to Member
Re: What in the world is "Refactoring?"
« Reply #11 on: January 03, 2011, 05:09 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.  :(