Code Monkey home page Code Monkey logo

refactoring-to-activerecord's Introduction

Refactoring to ActiveRecord

Fish.ly is back!

This time, you are inheriting a code base that was written by a consulting company. The only problem is that none of them had heard about ActiveRecord! Your goal for this exercise is to refactor the application to use ActiveRecord.

When you are done:

  • The tests should still pass!
  • There should not be any SQL in the Sinatra app (app.rb)
  • There should be no validation code in the Sinatra app (should use ActiveRecord validations)

You cannot change any of the tests! We want to make sure that behavior is EXACTLY the same after we introduce ActiveRecord. Since we only have acceptance tests, changing the tests would

Refactoring

This exercise will also give you practice refactoring code. Refactoring is defined by Martin Fowler as:

a change made to the internal structure of software to make it easier to understand and
cheaper to modify without changing its observable behavior

So when you are done with a refactoring, from a user's perspective there should be no difference. That is the "observable behavior" part of the definition above. Instead, the goal refactoring is to change the implementation of our code so that our code is cleaner and our app is easier to change in the future.

In the example, the refactoring we are going to perform is removing all SQL interactions from the Sinatra app and move that behavior into ActiveRecord. We will talk more in class about how to approach this problem.

refactoring-to-activerecord's People

Contributors

jetaggart avatar gnarargs avatar cpbuckingham avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.