Code smells, get really good at code smell (brown bag)
All you have to know is the codes smells
make a million new things > mutate objects
Forwardable (delegation)
Don't go on a virtical tangent, instead tiptoe away and finish the horizontal refactor
code smell: DATA CLUMP
want it to become an object
I know that to_s is mine,
The process of design is about discovery. The design will emerge.
Start with the highest level test, make that pass in the dumbest way possible
- should be a solid B
- alwasy asks for Churn vs complexity
- High in churn, low in complexity; ex: config files
- Log in churn, high in complexity; ex: sheet music for church quire app
- High in churn, high in complextiy; ex: user [DANGER]
most code doesn't matter, and you should not care about things that don't matter; churn vs complexity helps us understand about, stuff
Use for
for factories, use it consistently communicates intent, that it's always a factory.
Sadly must check type :( to return early if type is a BottleNumber
: it's a traditional shim to port to factory.
eventually ^ replace conditional with polymorphism.
"Pass me the object I'm supposed to operate on!"
- want less stable things to depend on more stable things
- String should not depend on me
MONKEY PATCH
- follows conventions of OO
- "Those objects are mine!"
- Not much fear of name colision
- Is name colision the only concern?
- Overriding a method that is used somewhere else; BIG ONE
- really hard to find the methods
- magic methods
- not really a natural extension of the object
- "smalltalk you ceate a DSL for your app", Avdi said and Sandi agrees.
- "Java people create brand new objects"
- When it's safe
- "I scalded my child once and now I'll never wash them"
- may never
- must intervene in the smallest possible way
- code must be needed in more than one place
- name has to be specific to your domain that the chance of override by ruby is nearly impossible.
- "restricted" monkey patch; use a refignment
- must check that it isn't already deifned.
CONVERSION (Avdi) alternative to ^
Integer('1')
- little different from
'1'.to_i
- idempotent ==
String('string') => 'string'
reduce polution in base classes
Avdi (make a little vidual graph)
|INPUT - NAME (smalest level of abstraction)
|data - shuffle
|DATA - <blank>
There are two distinct ideas, need orders.
Omega messes, Push all messes back into those