locked
Anyone know of a good source of information on refactoring? RRS feed

  • Question

  • Hello,

    I've just got into refactoring in a big way. I used to write large methods with lots of duplication, and knew it was a bad way to do it, but never had the patience to do anything about it. I recently discovered how easy it is to pull out methods, rename things and so on with VS and am hooked!

    I'm sure I'm missing a lot of what can be achieved with refactoring, as well as the best way to go about it.

    Does anyone know of a good resource for this? I want to learn best practices, when to do it, when not, how far to go, what can be done, etc. I don't mind if it's an online source or a book.

    Thanks

    Sunday, June 20, 2010 3:02 PM

Answers

  • Hi Mr Yossu,

    I highly recommend a book named "Essential Skills for Agile Development" which you can get it for free from http://www2.cpttm.org.mo/cyberlab/softdev/ESAD/download.html.en (Download Essential Skills for Agile Development).

    Best Regards,

    Yasser


    LEARN HOW WPF IS FLEXIBLE IN PRESENTATION DURING A QUICK SIMPLE WALKTHROUGH:
    Walkthrough: Displaying multi column ComboBox by using Windows Presentation Foundation (WPF) data templating
    • Marked as answer by YiChun Chen Friday, June 25, 2010 2:44 AM
    Sunday, June 20, 2010 6:24 PM
  • You could also try:

    Refactoring - Improving the Design of Existing Code
    Martin Fowler
    ISBN 0-201-48567-2

    I have this book; it's not too bad (but nearly all the stuff I've ever read anywhere on refactoring seems to fall into the "well duh" category ;).

    • Marked as answer by YiChun Chen Friday, June 25, 2010 2:44 AM
    Monday, June 21, 2010 9:21 AM
  • I think that if you're interested in refactoring, you should get Fowler's book. It's one of the definitive ones on the subject. NOTE: It is NOT specific to C#, rather, it is a more general look at the patterns of refactoring. All the code samples are in Java - but it's close enough to C# that you can easily see the patterns.
    • Marked as answer by YiChun Chen Friday, June 25, 2010 2:44 AM
    Monday, June 21, 2010 2:08 PM
  • I have the first of those two design pattern books. It's the definitive volume, so if you're going to get one, I'd recommend that one. :)
    • Marked as answer by YiChun Chen Friday, June 25, 2010 2:44 AM
    Tuesday, June 22, 2010 12:52 PM

All replies

  • Hi Mr Yossu,

    I highly recommend a book named "Essential Skills for Agile Development" which you can get it for free from http://www2.cpttm.org.mo/cyberlab/softdev/ESAD/download.html.en (Download Essential Skills for Agile Development).

    Best Regards,

    Yasser


    LEARN HOW WPF IS FLEXIBLE IN PRESENTATION DURING A QUICK SIMPLE WALKTHROUGH:
    Walkthrough: Displaying multi column ComboBox by using Windows Presentation Foundation (WPF) data templating
    • Marked as answer by YiChun Chen Friday, June 25, 2010 2:44 AM
    Sunday, June 20, 2010 6:24 PM
  • Thanks Yasser, that's looks like a good resource! Mind you, at 427 pages, I won't finish it tonight!
    Sunday, June 20, 2010 6:53 PM
  • You could also try:

    Refactoring - Improving the Design of Existing Code
    Martin Fowler
    ISBN 0-201-48567-2

    I have this book; it's not too bad (but nearly all the stuff I've ever read anywhere on refactoring seems to fall into the "well duh" category ;).

    • Marked as answer by YiChun Chen Friday, June 25, 2010 2:44 AM
    Monday, June 21, 2010 9:21 AM
  • Hello Matthew,

    Following on from some links in this thread, I ended up on Amazon last night looking at this very book! I have added it to my basket, but haven't decided whether or not I'm going to buy it yet. Maybe you can help me decide. How does it compare to any other books on the subject? Have you seen "Essential Skills for Agile Development " that Yasser mentioned? I've downloaded that and looked through it (albeit quite briefly), and it looks good, although it does seem to be long for what it seems to cover. There are a lot of code examples, some of which could easily have been shorter and made the same point.

    In the past, I never used to think of splitting code into smaller chunks, and so used to end up with huge methods, with lots of comments, and (probably) a lot of repetitive code. Since I discovered refactoring, I've been chopping the code up into much smaller, more useful and self-documenting methods. This is great, but unless refactoring is well overstated, there must be more I can do. That's what I'd like to learn now.

    For example, I first came across refactoring in a magazine article, where the author showed how he could take a nasty piece of code and improve it. He first extracted some methods, and then "after a couple of rounds of refactoring " (his words) ended up with a generic routine that was capable of being dropped into a wide variety of applications, and was flexible enough to be useful. I would like to know how to do that sort of stuff.

    Do you think that Fowler's book will help? I've got the basic stuff, I want the clever stuff!

    Thanks again

    Monday, June 21, 2010 2:00 PM
  • I think that if you're interested in refactoring, you should get Fowler's book. It's one of the definitive ones on the subject. NOTE: It is NOT specific to C#, rather, it is a more general look at the patterns of refactoring. All the code samples are in Java - but it's close enough to C# that you can easily see the patterns.
    • Marked as answer by YiChun Chen Friday, June 25, 2010 2:44 AM
    Monday, June 21, 2010 2:08 PM
  • OK, thanks. That book did look the best of the bunch, so it's good to hear you confirm my thoughts.

    As for the language, none of them seem to be in C#, but I'm not too worried. Most of the C-family are close enough that I would be able to work out what's going on. I don't imagine they get too heavily into advanced parts of the language, it's more about code structure. Whilst I'm no expert in it, I did some Java a few years ago, so should be able to read that fine.

    Whilst we're on the subject, do you know much about design patterns? As you can guess, I'm trying to get myself into the grown-up way of programming, and this seems to be a big subject. I saw two books on Amazon that have good reviews. Do you know anything about them (or others)?

    Design patterns : elements of reusable object-oriented software (http://www.amazon.co.uk/gp/product/0201633612/ref=ord_cart_shr?ie=UTF8&m=A3P5ROKL5A1OLE) which seems to be the one (of these two at least) to read first, and Design Patterns Explained: A New Perspective on Object-Oriented Design (http://www.amazon.co.uk/gp/product/0321247140/ref=ord_cart_shr?ie=UTF8&m=A3P5ROKL5A1OLE) which looks like a good second book.

    Any comments? Thanks again

    Monday, June 21, 2010 7:17 PM
  • I have the first of those two design pattern books. It's the definitive volume, so if you're going to get one, I'd recommend that one. :)
    • Marked as answer by YiChun Chen Friday, June 25, 2010 2:44 AM
    Tuesday, June 22, 2010 12:52 PM
  • Thanks, I've ordered it, along with Fowler's book.

    Now all I need is the time to read them!

    Tuesday, June 22, 2010 10:41 PM