Thoughts on Software by Andrew Davey
| | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| 24 | 25 | 26 | 27 | 28 | 29 | 1 | | 2 | 3 | 4 | 5 | 6 | 7 | 8 | | 9 | 10 | 11 | 12 | 13 | 14 | 15 | | 16 | 17 | 18 | 19 | 20 | 21 | 22 | | 23 | 24 | 25 | 26 | 27 | 28 | 29 | | 30 | 31 | 1 | 2 | 3 | 4 | 5 |
Search
Navigation
Categories
Blogroll
|

Monday, March 24, 2008
Test-Friendly Snooze
After beginning to use Snooze on a real project I realised it needed to be more extensible and more testable. So I re-wrote it!
The new code is now in the trunk: http://svn2.assembla.com/svn/snooze/trunk
A key extensibility point is the "ResourceContext" class. Before a resource is invoked, it's ResourceContext is initialised with relevant data such as HttpContext, invoke verb, GET view and file type. The base Resource class allows sub-classes to specify a particular ResourceContext sub-class, by the use of a generic type parameter. So when using Snooze in a web project it is easy to define extra context data that is always available to any resources. Instead of adding properties to a Resource class, the use of a context object allows data to be easily shared between a sub-resource and it's parent resource chain.
A Snooze resource also has a ResourceFactory object. The type of this is also generically typed so that a web project can provide a customized factory.
These changes make it easy to do things like test that a resource creates sub-resources (through the factory).
Monday, March 24, 2008 5:19:52 PM (GMT Standard Time, UTC+00:00)