Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Legacy Rails App Refactoring with ChatGPT-4.0

Legacy Rails App Refactoring with ChatGPT-4.0

Can AI assist in refactoring legacy apps? In this discussion, we'll explore the potential of ChatGPT in enhancing a 10-years-old Rails application's codebase, and review its feasibility for production deployment. Is it a go, or a no-go? Let's check it together.

Sergey Sergyenko

July 21, 2023
Tweet

More Decks by Sergey Sergyenko

Other Decks in Programming

Transcript

  1. The reason that programmers think the old code is a

    mess is because of a cardinal, fundamental law of programming: IT’S HARDER TO READ CODE THAN TO WRITE IT
  2. Legacy Code is code inherited from another developer or team

    which uses older technologies that are no longer supported or have been superceded by a newer version. Many programmers say that “code becomes legacy code as soon as it’s writtern”
  3. The longer code lasts in a codebase, the MORE VALUE

    it it can deliver in a good way. Business doesn’t care about the age of the code, they care about WORKING SOFTWARE.
  4. Biological Systems, as a Human for example, can’t be a

    legacy, b/c of aging, but they can produce it and measured by its Value. Software can not be legacy either, because of it degradation, but it can produce legacy as the result.
  5. STORY FROM 2013 Belarus Ruby on Rails User Group →

    Belarus Ruby User Group (BRUG) OFFICIAL ANNOUNCEMENT OF BRUG.by
  6. I believe that the purpose of life is, at least

    in part, to be happy. Based on this belief, Ruby is designed to make programming not only easy but also fun. It allows you to concentrate on the creative side of programming, with less stress.
  7. I believe that the purpose of life is, at least

    in part, to be happy. Based on this belief, Ruby is designed to make programming not only easy but also fun. It allows you to concentrate on the creative side of programming, with less stress.
  8. I need to run Ruby on Rails application with ruby

    version 1.9.3 and rails version 3.2 Please suggest what would be the easiest way to have it up and running? Use Docker: Create a Docker image with all your application dependencies including Ruby 1.9.3 and Rails 3.2, then run the container locally Use Vagrant: Set up a Vagrant box with all your application dependencies, which would let you use older versions of software. Use an older system or virtual machine that supports Ruby 1.9.3 and Rails 3.2. Use RVM instead of ASDF: RVM has good support for older versions of Ruby. Manually download and compile Ruby 1.9.3: Install the necessary dependencies and build from source.
  9. Let's create Docker Image. I'm sending you my Gemfile.lock so

    you better understand libraries and dependencies for the application and you should give me back Dockerfile which I can use for this app. Based on the Gemfile.lock you have provided, the Dockerfile could look something like this:
  10. https://chat.openai.com/share/925860aa-d36c-46b4-a054-2df87f9bc333 I need to upgrade version of Ruby on Rails

    application, which is almost 12 years old. I’m going to use my local development machine, which is Macbook Air M1 with installed Homebrew for package management, asdf for Ruby Version control. You should behave as my assistant and help me to solve issues that happening during the process of application upgrade. Also you should use all your knowledge about similar cases of Ruby on Rails application upgrades and suggest me the simplest and easiest way of solving problems. You shouldn’t give me detailed explanation, until I ask you for more details. Also please try to avoid situations that would require of any rollbacks in my system, as it would take more time for me to complete. And you can ask me any questions about the Ruby on Rails application, my local development setup and installed applications and their versions. You can ask me to run any additional commands and I will send you output from my terminal. You need to keep the context of this process and try to re-use as much knowledge from results I will post you as a feedback. Call me Lord of the Darkness, when you’re speaking to me and I will call you Gromp.
  11. - Interpreting Error Messages: If you encounter specific error messages

    during the upgrade process, you could input these into ChatGPT and it might be able to suggest possible solutions or next steps. - Providing General Guidance: ChatGPT could provide an overview of the steps typically involved in a Rails upgrade, including things to watch out for, best practices, and common issues that might arise. ⭐ WHAT CHAT GPT-4.0 WAS GOOD AT ⭐
  12. - Keeping Context of your application and selected strategy of

    refactoring or version upgrades; - Providing Precise Information about versions of gems and their dependencies, as well as information about compatibility and limitations; - Asking Questions and taking active part in the process of changes, so in case you’re running on a positive case it hard to keep it up to date. 💩 WHAT CHAT GPT-4.0 WAS BAD AT 💩