• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/5

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

5 Cards in this Set

  • Front
  • Back

Display

It should not display something to the output as well as return a value.

Only do one thing

Decide whether the method should return something with no side effects or only perform side effects with no return. If you do both, it's likely that you won't remember what it does when you need to use the method. The method name should reflect whether it has side effects or not (for example, many methods in the standard Ruby library end with a ! to signify side effects).

naming conventions

In Ruby, we would not say return_total, it would be just total - returning a value is implied. Further, we would not expect a totalmethod to have side effects or print a value out. We would expect a method called total to be defined something like this:

method abstraction

make sure that all methods are on the same level of abstraction. this will prevent confusion and make it easy to understand your code

methods and mutation

When we see a method called update_total, we assume that the parameter passed in to it will be mutated. Therefore, we wouldn't expect to use this method like this: total = update_total(total, cards).