My Life As A Blog

Archive for December 2006

Action Man

leave a comment »

Roy Osherove has posted about a validation framework called Validation Everywhere.  It has a lot in common with nspectre (for instance, both make it easy to unit test your validation logic) – the approach is a little different and Validation Everywhere doesn’t seem to have actions (yet.)  Actions are a key concept in nspectre.  They allow you to group specifications.  In practice this is likely to mean things like Add or Delete.  Because actions can inherit from other actions, specifications that are common to a number of specifications can be grouped together and don’t have to be repeated.
I have been asked before why nspectre doesn’t use attributes.  The answer is linked to actions.  A property on a class may need to be a certain length.  It is likely that this need is context sensitive – i.e. we don’t need to check if the property is of the correct length if the object in question is being deleted.  Moving the knowledge of the context outside the class makes it easier to maintain.  It also creates possibilities that would otherwise be very difficult.  For instance, I have spoken to one developer who maintains a site where the validation rules are user specific (e.g. when each user registers and is set up, they can choose how long fields should be and which are mandatory.)  This requirement could be supported in nspectre by having a configuration per user (and one ValidatorFactory per user.)  I guess it’s also worth noting that Context can be used to pass runtime information to specifications.  Context could conceivably be used to the same end – the better approach would be determined by how different the logic was between users.


Written by remark

December 17, 2006 at 7:58 pm

Posted in nspectre

Django Bells

with 4 comments

Having been through the whole Django tutorial now, I’ve started to explore on my own.  What I’ve done so far has felt fairly intuitive.  I haven’t done enough to feel like I know what I’m doing, but at the same time I feel a lot more comfortable than I have with other frameworks at the same stage.
At this point I like to read a book to get more detail.  And guess what?  I found one on-line – The Django Book.  Haven’t had a chance to look at it in too much depth yet, but the fact that you can see other reader’s comments about the text is interesting – and should provide a more rounded view.  That’s my Christmas reading sorted out.

Written by remark

December 10, 2006 at 7:23 pm

Posted in Development, Software

You don’t want to do it like that

leave a comment »

James Carr has compiled a useful list of TDD Anti Patterns.  Worth reading.  And if you want to read more about unit testing, may I recommend Michael Feather’s book, Working Effectively with Legacy Code?  This is a great book that describes refactoring techniques you can apply to apply unit testing to existing, untested code – the sort of code that often feels untestable.  After reading this book I felt that in addition to being able to tackle legacy code, I had a much more instinctive feel for how to design code to be testable.  James’ post helps to keep the tests you’re writing clean.

Written by remark

December 7, 2006 at 10:22 pm

Posted in Unit Testing

nspectre 0.9.0

leave a comment »

I’ve released nspectre 0.9.0.  This release contains a schema against which XML configuration files are validated.  There is also an XSL so that existing files can be updated to the new format.

The other new feature is templated error messages.  The properties used by a template can now be used in the error message.

Get it here.

Written by remark

December 3, 2006 at 4:06 pm

Posted in nspectre