2 ms·
> I find that people that have the hardest time writing tests have poorly-architected applications that don't lend themselves to easy testing. It's generally g
by irahul 15y ago
> I find that people that have the hardest time writing tests have poorly-architected applications that don't lend themselves to easy testing.
It's generally good to start with some framework which provides capabilities to easily mock most of the objects. You sure can architecture your application as such, and have your dependency_injection_thingie to mock objects, but I don't think it's a worthy investment of time.
> (Who would have predicted the day where I started writing my HN examples in Python!)
So why is that? Working on a Python application? While you are there, check out decorators and co-routines/generators. You already have checked out decorators(which are basically function composition - same in Perl other than the syntactical sugar) - I see your @memoize example.
Decorators along with Python introspection are super cool. I used decorators to implement a small contract system - https://github.com/thoughtnirvana/augment https://github.com/thoughtnirvana/augment
I recommend this talk on co-routines http://www.dabeaz.com/coroutines/ http://www.dabeaz.com/coroutines/
EDIT: Perl has coro. But the language integration(generator expressions, convenient yield) makes it a bit more natural in Python(YMMV). And Python has gevent if you are looking for a threading equivalent.