If you can't read please download the document
Upload
andrew-grimm
View
761
Download
0
Embed Size (px)
Citation preview
Mistakes? I've had a few
Andrew Grimm@andrewjgrimm
Excessively large classes
CausesAdding new features
Fear of passing around data
Not a problem until modifying existing code was required
Excessively large classes
Break into smaller classes
Or modules if you must
def_delegator :@sub_object, :method_foo
Side effects
Does your method really need to produce output? Can't it produce a string instead?
You can manipulate strings. You can't manipulate output.
Side effects
When testing, how often are you interested in writing to file or writing to a DB?
Aren't you interested in the contents instead?
Side effects
Side-effect-free code is easier to test, faster to test, and safer to test
Schlemiel the painter
Doing something a million times you only need to do a few times (literally!)
Often the result of mixing separate tasks together
Why maintainability matters
Additional functionality
Modifying functionality
Improving performance
Testing
If you can't write tests, it may not mean you're bad at testingIt may mean the production code is bad
Version control
Best form of documentation I had
What was I thinking when I wrote that code?
Large commits are a code smell