yaml, an alternative for XML

yaml is an serialization data language, an alternative to the markup language of XML. And I think is pretty cool their use it, because really is more readable than XML. It’s focus on the simplicity. Let’s go to an example took from the reality, this is how an NHibernate mapping file should look with the yaml format:

If you use NHibernate, you know, this is too much easy to read. As you see the delimitation is made for the indentation, if you know something about languages like Python this is very familiar. Of course, this is not provided, but who knows, maybe someone want to donate some hours to the OSS and make it ;)

Maybe a notorious disadvantage is that yaml don’t have schema. And you can guess the missing features because of that, the most important is the yaml-validation.

In the .Net world is not so popular, but in languages like Python, Php, Perl, C++ is well used. In the brand new baby of Google: Google App Engine, which the main language of the core is Python (actually right now is the only one supported) uses yaml of data definition.

XUnit 1.0 – Using ReSharper as Runner

Today I heard about this drop, that actually I was waiting for it. Time ago when this brand new project was release, we talked about it(Spanish post).

We have to remember that exist many Unit Testing frameworks, and XUnit is an special one, has many distinctive differences respect another frameworks like NUnit. Although the creator of XUnit is the same whom create NUnit, these projects are quite different. The main idea that led to creation of another new Unit testing framework for .Net was to leave some aspect that NUnit had strongly inherited from they source of inspiration: JUnit.


Download XUnit 1.0

To run the tests with XUnit we can use different runners:

  • xunit.console (included at XUnit’s binaries)
  • xunit.gui (included at XUnit’s binaries)
  • TestDriven (integrates with Visual Studio)
  • Resharper 3.1 (integrates with Visual Studio)

Here you can see XUnit in action running into Resharper:

NHibernate.Burrow 1.0 alpha released !

I’m very glad to announce on this blog this news. Yes, NHibernate.Burrow is ready to download here, make a try, we need feedback.

But...what is NHibernate Burrow ?

NHibernate.Burrow is a light weight middleware developed to support .Net applications using NHibernate  as ORM framework by providing advanced and smart session/transaction management and other facilities.

Kailuo Wang, leader of NHibernate.Burrow, was working really hard on this project (and will continue doing it). Also with help of Nelo Pauselli, and Fabio Maulo. The official announce was made here.

Kailuo, is a good programmer and make good wikies too :) So, documentation about Burrow be found here.

Maybe if you felt the need of use NHibernate on Web, Burrow, could be your option. And maybe you can remember this super-visited article at Code project. This article talk about some good practices when you use NHibernate on a web enviroment. Good news for you, the examples on Burrow are based on this tutorial. This example be found on the SVN of NHibernate Contrib here. Check it out !

NHibernate 2.0.0Alpha1 released

Here is the link to download:


[Download here]

Db4o – Field Generation support

I think the field generation in Db4o could be a cool feature. When I talk about field generation is a kind of interception before save/update on an object letting to a generator set a value on a specified field.

The field generation is not a primary key generation! Maybe, this feature may able make more easier the implementation of an Auto-Increment field generation for example.

Like an exercise, and to learn about the inside-of-Db4o I’ve implemented this feature in an a local working copy. Let see some code and how to use it.

First, to be able to create field generators you have to implement your own generator via the interface IFieldGenerator. And this is a simple example of an generator: a Guid generator.

Now, lets see the objects where the generation should occur. We have an hierarchy of Animal <- Dog.

 

Now we want to inject a value into the field id before an object-Insert. For make this happen we must to configured Db4o with a code like this:

And that’s all. Before of an Insert, the object will be injected with a new Guid value. Lets see the code in action in a test method:

 

An interesting point here is the polimorphistic behavior: we have configured the Animal class, and later the field is injected in a instance of a Dog class.

You can configure this feature using attributes/annotations. In order to do that you on have to denote the class with the attribute GeneratorAttribute. And this attribute receive the parameter of the generator.

GeneratorAttribute make the magic because it just inherit from IDb4oAttribute interface, and later via the ConfigurationIntrospector we configure Db4o as usual. Cool isn’t ?

[Download the example]

And apply this patch at the revision 10450 in order to see the changes on the code.

Movements on NHibernate.Contrib

The non-Core projects on NHibernate are on moving into NHibernate.Contrib. This is the list of projects that we can use and its states:

  • NHibernate.Burrow/
  • NHibernate.Caches.MemCache/
  • NHibernate.Caches.Prevalence/
  • NHibernate.Caches.SysCache/
  • NHibernate.Caches.SysCache2/
  • NHibernate.JetDriver/
  • NHibernate.Mapping.Attributes/
  • NHibernate.Shards/
  • NHibernate.Tasks/
  • NHibernate.Tool.hbm2net/
  • NHibernate.UserTypes.Oracle/
  • NHibernate.UserTypes.SqlTypes/
  • NHibernate.Validator/
  • NHibernate.Search (not moved yet)

    The new projects here are: Search, Validator, Shards and Burrow. The first two are ready to use. NHibernate Shards is on development (I’m working on it) and Burrow is on development by Fabio Maulo and Kailuo Wang.

     

    NHibernate Shards need some improvements on NHibernate-Core to make the port a little more easier (i.e. Entity-Name).

  • NHibernate 2.0 – Examples and presentation (in spanish)

    The past week I were with the great Fabio Maulo at the MUG on Buenos Aires (ARG) talking about NHibernate 2.0. The 2 meetings were really good where we could go deep inside into NHibernate, to see many things not so much popular and new things as well.

    The examples that we made with the Diego Jancic help had the particularity of to be test projects. If you need debugging into you must use Resharper or TestDriven to handle it.

    You can get the examples above, and I apologies because I hadn’t time to translate it into English:

    Download Examples and Presentation

    NHibernate Validator on Winforms

    NHibernate.Validator is a framework to validate objects, and has not restrictions about where in your code you want make the validation. Figured it might be cool make an example when use this framework at the UI, for example onto Asp.net or Winforms. For now lets do it on Winforms.

    The next form with a couple of textbox is going to be validated:

    Ok now, how this form was validated?  Easy, using NHibernate.Validator and some helper classes that you can find on Suricato.Winforms.Validation. The ViewValidator class is the encharged of bind the controls and rules. This is the configuration:

    As you can see the ErrorProvider, that will show the inconsistencies on the values, it’s passed to the ViewValidator. Practically ViewValidator bind an UI control with the belongings rules of an object’s property. The “tFirstName” TextBox belong with the property’s rule of “FirstName” on the Customer class. Then we add the event that will do the control validation.

    Could that be made in a easiest way?  Yes, with a similar schema the SmartViewValidator class do bind the objects and the event registry of an automatically manner. Look:

    SmartViewValidator do for us some automatically things. With less code you can do the same job, but we need to be a little conventional on our code.

    The controls, must have the prefix in lowercase, following with the property’s name that it’s representing. For example, if we have a control named as “txtName”, the property’s name will be “Name”; if we have “dtpDate”, then this DateTimePicker will belong to the property “Date” on some class.

    We need to remember of initialize this controls after call InitializeComponent() to avoid nullability on ErrorProvider.

    How look our class with NHibernate.Validator’s attributes ?

    So, you can put NHibernate.Validator where you need to validate some code with pre-builded rules or custom rules made by you too. With only configure 1 line of code and everything is integrated with the UI.

    Download the example of NHibernate.Validator + Winforms

    Porting Hibernate Shards

    NHibernate Validator now it’s ported at a 98 %, rest some details that I gonna take into a account later. For that reason I begin the port of Hibernate Shards.

    NHibernate Shards will allow extend the NHibernate core for in order to get Horizontal Partitioning in our databases.

    Stay tuned, you gonna hear more about Shards. Meanwhile, you can take a look at SVN for code.

    NHibernate Validator ready

    The port of Hibernate Validator it’s ready. You can reach it at NHibernate.Contrib trunk. For documentation you can take a look at Hibernate.Validator Documentation and for examples I think that the tests are the best example.

    [Post updated 01-march-2008]