Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Rails refactoring can become complex

 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • 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
  • 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: 423
    • Mark post as helpful
    • send pies
    • 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
    • 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
    • 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.

     
    Anderson gave himself the promotion. So I gave myself this tiny ad:
    Two software engineers solve most of the world's problems in one K&R sized book
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
      Bookmark Topic Watch Topic
    • New Topic