Primitive Obsession¶
Using the 3 Rules below, you'll look for cases of the Primitive Obsession code smell.
Three Rules of Primitive Obsession¶
- It's an Unconstrained Type (not local variable)
- It's used in Logic/Comparisons, Calculations, or a Loop
- It is not the sole concern of the class that it's in
Find Primitive Obsession in Blackjack¶
-
Look through the three classes,
Card
,Deck
, andGame
. What are candidates for elements that have the Primitive Obsession code smell?Note
Ignore
equals()
,hashCode()
, andtoString()
methods as these were code-generated. -
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.
-
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!