This week we walk through some awesome tips from Pragmatic Programer Chapter 3. We talk through debugging strategies, challenging assumptions and more.
Stubs/doubles vs mocks
Stub is simple fake object. It just makes sure test runs smoothly.
Mock is smarter stub. You verify Your test passes through it.
Good stack exchange link on this
JP: "what does your program think is going on": DON'T BLAME EXTERNAL FACTORS FIRST. It's probably your code haha!
John: why, when faced with a "surprising" failure, you must realize that one or more of your assumptions is wrong.
JP: "routine" code isn't infallible! did you test all of the edge cases?
I really like the debugging checklist so here it is:
John: Duplicate the problem in tests.
examples of text manipulation:
JP: Funny enough, Hunt and Thomas like using Ruby (and Perl) to quickly hack short scripts
John: I want to push more into this - Just barely experimenting with self-creating API docs. Even just things like in ruby: writing a rake task to pull out all your custom objects and methods to start docs and get a clear picture has been helpful for me.
passive vs active code generators
passive = run once to produce a result
active = run every time you need a result. results are then thrown away
JP: meta programming? code gen doesnt have to be meta
John: Refactoring methods to "Find common resources" based on "Model" name - Reducess code significantly.