NBusiness on CodePlex feels like a Ruby app

NBusiness is an Entity Definition Language focused on the creation of business entities.  Basically, you use a construct called E# to build a code file, which is then ‘compiled’ into C#.  Basically, NBusiness acts as a domain specific language for the creation of business entities. 

Below is an example of some E# code.  It’s still a bit stinted in the structure, but it ‘feels’ like English to me, much like an internal DSL in Ruby.  (Even node the TRIVIAL creation of security around roles near the bottom of the example.)

It seems people are really getting into the Domain Specific Language thing…  But not the way Microsoft seems to be going.  Microsoft seems to be focusing on the big, graphical DSL model.  It’ll be nice when they get there, but meanwhile, they’2013-08-28 13:39:53’re being left in the dust by the folks just creating very clean, very fast DSLs for a particular domain.

Nicely done, guys!

family BeerBase.Business
{
    entity Address as EntityBase, EntityBaseCollection, EntityInfo, Scripts
    {
        field auto id int AddressId;
        field string Street1;
        field nullable string Street2;
        field string City;
        field string PostalCode;
        field int RegionId;
        
        relationship Kegbots with Kegbot on AddressId=AddressId as child;
        relationship Companies with Company on AddressId=AddressId as child;
        relationship Region with Region on RegionId=RegionId as parent;
        
        validate Street1 required;
        validate City required;
        validate PostalCode required;
        validate RegionId required;
        
        validate City minlength 2;
        validate Street1 maxlength 50;
        validate Street1 minlength 3;
        validate Street2 maxlength 50;
        validate City maxlength 50;
        validate PostalCode maxlength 16;
        validate PostalCode minlength 5;
        
        authorize allow * retrieve;
        authorize allow Administrators delete;
        authorize allow Administrators create;
        authorize allow Administrators update;
    }
}


Pin It

Comments are closed.