Friday, September 24, 2010

Model Driven Development with PyModel

A taste of the possibilities of the Model-Driven milieu.

This is a graph of a simple interaction involving one user sending emails to our app to sign up for some service.

Once the system is initialized (1), it receives an email and marks that sender as 'pending' (2) and then it receives a second email and marks them as 'active' (3). The model glosses over handling things like errors, timeouts, cancellations, replies sent from the server, etc., in order to make it easier to understand the model composition we do next, but we can expand the model to handle them,


click here for full image

That's pretty simple, but now think about trying to test that your app can handle more than one user signing up at the same time. There are several ways in which even just two users can interact with the above process.

Using the PyModel tools we can compose the following tiny piece of code with the EmailSignupModel model to add a second user to the composed model.


import EmailSignupModel
EmailSignupModel.users.append('OleBrumm')


The PyModel tools can then automatically generate this model:


click here for full image

Take a close look at that image and follow some of the paths through the graph. You'll find that each path through the graph corresponds to one possible sequence of interactions of the above simple process with two users.


You can use the generated graph to test that your application can, in fact, handle more than one person using it at the same time.