Skip to content

Primitive Obsession

Using the 3 Rules below, you'll look for cases of the Primitive Obsession code smell.

Three Rules of Primitive Obsession

  1. It's an Unconstrained Type (not local variable)
  2. It's used in Logic/Comparisons, Calculations, or a Loop
  3. It is not the sole concern of the class that it's in

Find Primitive Obsession in Blackjack

  1. Look through the three classes, Card, Deck, and Game. What are candidates for elements that have the Primitive Obsession code smell?

    Note

    Ignore equals(), hashCode(), and toString() methods as these were code-generated.

  2. For each item that you think has Primitive Obsession, make a note of it as well as why it has Primitive Obsession. Do not make any code changes at this time.

  3. After the lab is over, you'll be asked to share what you found, so type your notes in a convenient place.


You are done!