GithubHelp home page GithubHelp logo

oop_3's Introduction

Delegation

Delegate, delegate, delegate โ€“ Russ Olsen, Design Patterns in Ruby

This is a workshop to introduce you to the idea of Object-Oriented delegation.

Learning objectives

  • Describe "delegation" as "one class telling another class to do something and the other class encapsulating how to do it."
  • Explain what is meant by the advice "delegate, delegate, delegate".
  • Implement OOP delegation.

Delegation

In delegation, one class tells another class to do something and the other class encapsulates how to do it.

Look at the company structure code sample for an example of delegation.

Look at this diagram of the company structure code that shows the delegation relationships.

Instructions

This project contains two implementations of a todo list: /terrible and /great.

/terrible implements the features using a poor understanding of the delegate principle. /great implements the users stories using a good understanding of the delegate principle. /great is unfinished.

You job is to finish it.

Running the tests

$ cd terrible/   or   cd great/
$ bundle install
$ rspec

What code should you write?

  • Port the functionality in /terrible over to /great.

  • Examine the code and tests in /terrible to find out what functionality to implement.

  • Continue using the delegate, delegate, delegate approach in /great.

  • There are a few passing unit tests in /great. You will probably want to add to these.

  • There are some feature tests in great/spec/feature_spec.rb. These are currently failing. They should pass when you've implemented all the functionality.

oop_3's People

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.