DBC

Søren on DBC

Recently, Søren Skovsbøll wrote a excellent follow up to a little post I did a while back on using C# 3.0 expression trees for representing predicates in design by contract. The conclusion of that series was that C# was inadequate in lots of ways to the task of doing design by contract. Having said that, you can still achieve a lot using serialisation of object states and storage of predicates for running before and after a scope.

Søren was not happy with the format of errors being reported, nor the potential for massive serialisation blowout. Rather than comment on the blog, he went away and did something about it. And it’s pretty good! Go take a look, and then pick up the baton from him. Your challenge is to extract the parmeter objects from the expression trees of the predicates and take lightweight snapshots of the objects refered to. You also need a “platform independent” way to serialize objects for this scheme (i.e. one that doesn’t depend on XmlSerialisation or WCF data contracts.

Think you can do it? Apply here! :P

Dbc in the persistence broker

The work is well under way now, and I have reverse engineering, code generation and configuration pretty much sorted out, with a bit of code generation to make the whole thing compile nicely within an AabsNorm generated nant script that will take care of building the domain model, base objects, interfaces, mock objects etc.

At that point I shall put a bit of effort into making some WIX installers to allow me to quickly set up a development environment. That way the volunteers will come flooding in right?

Anyway, I've been using AabsNorm as a test bed for my last open source project Aabs.Dbc, a design by contract framework in C#. Here you'll find a sample of how the AabsNorm code will look when it gets released next.

DBC in use

I am finally getting around to making use of Aabs.Dbc in my new open source porject Aabs.Norm. I figured that the best proving ground for a thing like this is a thing like that. That is, a highly complex, high performance application framework, that maintains a state in a variety of very complex ways, that uses polymorphism and .NET in sophisticated ways, and that will be adversely affected if the performance of Aabs.Dbc is poor at runtime.

Here’s an example of the interface to the core object – the Persistence Broker.

namespace Aabs.Norm.Core

{

    public interface IPersistenceBroker

    {

            [Requires("criteria != null")]

        PersistentObject RetrieveObject(Criteria criteria);

            [Requires("persistentObject != null")]

            [Ensures("$before(persistentObject) ==

                $after(persistentObject)")]

            [Ensures("persistentObject.IsPersistent == true")]

            [Ensures("(persistentObject.TimeStamp - DateTime.Now) < new TimeSpan($time_ms)")]

            [Ensures("$result != null")]

            [Ensures("$result.Count == 0")]

        IList SaveObject(PersistentObject persistentObject);

            [Requires("persistentObject != null")]

            [Ensures("$before(persistentObject) ==

              $after(persistentObject)")]

            [Ensures("$result != null")]

            [Ensures("$result.Count == 0")]

            [Ensures("persistentObject.IsPersistent == false")]

        IList DeleteObject(PersistentObject persistentObject);

            [Requires("criteria != null")]

            [Requires("criteria.ForClass != null")]

            [Ensures("$result != null")]

            [Ensures("$result.Count >= 0")]

        IList ProcessCriteria(Criteria criteria);

            [Requires("persistentObject != null")]

            [Ensures("$before(persistentObject) ==

              $after(persistentObject)")]

            [Ensures("$result != null")]

            [Ensures("$result.Name != persistentObject.

                GetType().Name")]

        ClassMap GetClassMapFor(PersistentObject persistentObject);

            [Requires("tableMap != null")]

            [Ensures("$result != null")]

            [Ensures("$result.Count >= 0")]

        IList GetReferrersTo(TableMap tableMap);

            [Requires("persistentObject != null")]

            [Ensures("$result != null")]

            [Ensures("$result.Count >= 0")]

        IList GetLinkedClassMaps(PersistentObject persistentObject);

            [Requires("classMap != null")]

            [Ensures("$result != null")]

            [Ensures("$result.Count >= 0")]

        IList GetLinkedClassMaps(ClassMap classMap);

            [Requires("classMap != null")]

            [Requires("propertyName != null")]

            [Requires("propertyName.Length > 0")]

            [Ensures("$result != null")]

            [Ensures("$result.Count >= 0")]

        IList IncomingConnectionsToAttribute(ClassMap classMap,

           string propertyName);

            [Requires("procedureName != null")]

            [Requires("procedureName.Length > 0")]

            [Requires("type != null")]

            [Requires("databaseName != null")]

            [Requires("databaseName.Length > 0")]

            [Requires("parameters != null")]

            [Requires("parameters.Count >= 0")]

            [Ensures("$result != null")]

            [Ensures("$result.Count >= 0")]

        IList ProcessStoredProcedure(string procedureName,

            Type type, string databaseName,

            NameValueCollection parameters);

            [Requires("procedureName != null")]

            [Requires("procedureName.Length > 0")]

            [Requires("type != null")]

            [Requires("databaseName != null")]

            [Requires("databaseName.Length > 0")]

            [Requires("parameters != null")]

            [Requires("parameters.Count >= 0")]

            [Ensures("$result != null")]

        string ProcessStoredProcedureRaw(string procedureName,

            Type type, string databaseName,

            NameValueCollection parameters);

        bool ProcessTransaction();

    }

}

And we’re off

I have set up the sourceforge project. You can find it here. I've also classified all of the work, and split it up into releases.

Here's what will go into release one:

Configuration Use native .NET configuration
Configuration Remove existing config assembly
Installers WIX installers
Runtime Control Add transactional support from COM+
Runtime Control Extend reverse engineering to examine SPs and create wrappers for them.
Runtime Control Configurable ID strategy
Runtime Control Configurable transaction isolation policy
Templates Move core templates into resource assembly
Testing Create a proper test database
Runtime Control Divide system between runtime and development projects
Runtime Control Standardise all names to CamelCase

I think the highest priority is the configuration rework. Configuration in the previous system was way too complicated. What we need is a very simple, very reliable system that can easily be expanded to accommodate something like the config app block at a later date. As soon as that is done, the key task will be converting it from its current broken state to a working state, and then splitting the system up into runtime and development arms. I will also do some work towards creating WIX installers for the runtime and development systems, including an installer for packaging source releases, that will allow the easy setup of a development environment for new volunteers on the project.

This is of course based on the "if you build it, they will come" model of open source development.

I’ve done my civic duty for the year…

Well, Aabs Dbc is now out there in the public domain now. Yayyy!!!!!

I've created an open-source project on sourceforge, and advertised there for help with documentation, installers and general app developers. I've uploaded an initial source code release – and configured my paypal settings.

I can't wait to see how it is received by the public. Pay the site a visit, and let me know what YOU think. And, of course, if you want to make a donation… ;o)

Here's the SourceForge link.

The big day has arrived

Well, it's all out there in the public domain now. Yayyy!!!!!

I've created a project up on sourceforge, and advertised there for help with documentation, installers and general app developers. I've uploaded an initial source code release – and configured my paypal settings.

I can't wait to see how it is received by the public. Pay the site a visit, and let me know what YOU think. And, of course, if you want to make a donation… ;o)

Here's the SourceForge link.

Here goes…

I have taken this stuff to the point where it is not too scruffy to release to the world. What I need to do now is publicise it to the world at large. Any ideas about the best forums for that?
I think SourceForgeand gotdotnet will help, but I can also imagine that sharptools and USENET might be good avenues to publicise it through. How will I manage the project when I open the code up to the open source community?

The SourceForge project location is here.
The GotDotNet project location is here.