Giter Site home page Giter Site logo

ajax-oop-refactor-lab's Introduction

Ajax OOP Refactor Lab

Objectives
By the end of this lab, developers will be able to...
Refactor Existing Front End JavaScript into OOP
Reinforce OOP JavaScript concepts

Where We Are

In the last lab, we did some test-driven development (TDD) to create a JSON api using Express.

For this lab we are going to take the front-end JavaScript we were given and refactor it into OOP.

Requirements

  1. Inside of the document ready, we should declare
    var app = new App();
  1. Methods can be called on app from inside the document ready,
  app.render();

but nothing should be defined in there!

  1. Define all of your variables on App:
  function App(){
    this.baseUrl = '/api/todos';
    ...
  };

Think-pair-share: Look at the code and think of some other properties we would need in our App() constructor.

  1. Attach all of your functions to App's prototype:
  App.prototype.render = function() {
    this.$todosList.empty();
    ...
  };

Think-pair-share: Look at the code and think of some other methods we would need in our App() prototype.

  1. Try to set this up in small steps, and when in doubt (as often as possible), run the code and debug errors one by one.
  2. When you are finished you should be able to create, read, update and destroy todos on your app!

Resources

OOP in JS: What you need to know

Licensing

All content is licensed under a CC­BY­NC­SA 4.0 license. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].

ajax-oop-refactor-lab's People

Contributors

awhit012 avatar zebgirouard avatar

Watchers

 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.