• 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
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Rails refactoring can become complex

 
Ranch Hand
Posts: 430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. In this interview http://www.artima.com/articles/flex_in_the_enterprise.html, the developer explains that he had difficulties performing larger refactorings.

How do you deal with this problem as your codebase growns?

Thank you!
 
author
Posts: 11
Ruby
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Large refactorings are largely a mistake. The three important guidelines for dealing with any refactoring are:

  • Cover the existing behavior with integration tests. Simple smoke tests are a huge win for ensuring you're not breaking existing functionality.
  • Focus on a small part, one at a time. No matter how tempting it is to fix the whole application in one sweeping chunk, small iterations are always better.
  • Red, Green, Refactor. To avoid amassing a large chunk of technical debt, you should always be cleaning as you go.


  •  
    Leandro Coutinho
    Ranch Hand
    Posts: 430
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Yes, I agree. What IDE do you use? If you want to change the class' name. Is the IDE capable of change it everywhere?
     
    Sheriff
    Posts: 1367
    18
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    In ruby there isn't a lot of (any?) tool support for automated refactorings, the reason being that the ruby language is extremely dynamic and objects can be defined at runtime. It's pretty hard to detect something that doesn't exist yet :)

    I believe RubyMine may have the closest thing to refactoring support, but I haven't ever used it so I wouldn't trust my judgement on that.
    Most people I know just use textmate or vim with various plugins, macros, and bundles.

    Thus, it is more important than ever to lock down existing behavior with characterization tests / integration tests.
     
    Tammer Saleh
    author
    Posts: 11
    Ruby
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Katrina is right in that a lot of the reason for the lack of IDEs with features comparable to those in the Java world is due to the dynamic nature of ruby. It's technically difficult to know what methods exist, for example, when methods are often created at runtime.

    On the other hand, this same dynamic nature makes a lot of the refactorings that IDEs traditionally offer less important. Ruby enables very DRY code, meaning there's very little boilerplate sitting around, and most refactorings are just as easy to accomplish with a good text editor.

    My personal "workbench" is simply:
  • VIM in one window with custom configurations, and Tim Pope's wonderful Rails Vim plugin. I've also blogged about using pathogen to manage your vim configs.
  • Autotest running in another terminal. Autotest (part of the ZenTest gem) simply watches for changed files and runs the appropriate tests. Makes for a very fast TDD workflow.

  • Sprinkle in a browser or two for click-testing and viewing docs, and that's about it.

     
    straws are for suckers. tiny ads are for attractive people.
    free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
    reply
      Bookmark Topic Watch Topic
    • New Topic