| Programming these days seems to be more of an exercise in managing unexpected complexity between various components or pieces of code. Here's a few tips: 1) Unit test. 95% of your test suite should be unit tests. Objects under test should not require the entire codebase to be loaded in order to perform... ideally they depend on nothing, or just 1 or 2 things (which in turn hopefully depend on nothing, or just 1 or 2 things, ad nauseum). 2) Don't mutate passed-in arguments. In fact, mutate as little as possible. 3) Don't use objects with potentially unexpected, surprising or unknown behavior that makes it difficult to reason around the code (QUICK- what happens when you merge a ruby HashWithIndifferentAccess with a regular hash containing both similarly-named symbol and string keys?) 4) Use function objects, that have zero side effects, wherever it makes sense. (Or just use an entirely functional language.) 5) Separate components that talk to each other through I/O should use something like the circuit-breaker pattern http://martinfowler.com/bliki/CircuitBreaker.html 6) Microbenchmark things. Individually, a series of tasks might all "look" fast, but when run 10000 times in a row, might expose unreasonable resource utilization. |