Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7015991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:43:31+00:00 2026-05-27T22:43:31+00:00

I’m working on a quite large legacy Rails app. Most of the code is

  • 0

I’m working on a quite large legacy Rails app. Most of the code is downright horrible, and I’m trying to make it better as I go through it.

The problem is, there are no tests, and almost everything is wrong. So far I’ve went through the code and made a lot of handwritten notes on stuff that needs to be refactored, so that I can later do it when I get to adding tests.

But there are things that are just so simple and scream for quick refactoring. For example:

def isValid(valid)
    name = Long::AndUglyModule::UglyClass.getvalid(valid)
    return name
end

the whole class looks like this, which makes me wanna just rewrite it to

include Long::AndUglyModule

def is_valid(valid)
  UglyClass.getvalid(valid)
end

the problem is, that I’m afraid of introducing some subtle mistakes. On the other hand, working with code that looks like this gives me loads of headaches.

Is it better to just do simple refactorings instantly, or leave the code as it is until I actually have to work with it or change it directly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:43:31+00:00Added an answer on May 27, 2026 at 10:43 pm

    I have much experience with huge legacy code and entire refactoring.

    • Allow a hybrid of new and old.
    • Clearly separate both code bases.
    • Log exceptions.
    • Making the old code more beautiful can be a 10000% waste of time.
    • Refactor first where it makes sense: remove HTML framesets, declarative navigation. Small functions for cumbersome constructs.
    • Make a source processing app, translating antipattern in the code to better code. Multisource regex find and replacements are needed too, \1 for recognizing a repetition.
    • Introduce methods where the old code was too long.
    • Shrink code: copied & edited pieces to a business logic class keeping all together.
    • Process source wise.

    Before all: start with statistics, KB, number of lines, percentage processed, time line. With a google spread sheet one can communicate the progress, and calculate the end date.
    That legacy code takes much time is underestimated, so be sure you have good documentation.

    There is much more to say, but this is what immediately relates to “small refactoring.”

    Conclusion:

    One really cannot and should not do anything against the inherent urge of a programmer to refactor small pieces, but refactoring should either be a conversion over multiple sources and occurrences, or while a single use-case is corrected or redesigned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.