Retina.NET default persistent data on entities

Tags: ORM, Retina.NET

Hi, currently Retina.NET defines as persistent public fields and public properties.
If you want to change that behavior you must use attributes. For example, to make a private field persistent you must add an attribute, the same is for making a public property non-persistent.

Well, I want to change that behavior and make only fields persistent by default.
The reason for doing this is that in general persistent data is something internal to the entity (it's state) and have nothing (or little) to do with the behavior of the entity.

One example of this is the use of properties for automatic databinding. Automatic databinding works only over properties and not fields, so we endup having a bunch of public properties with non-persistent attributes. I think that pattern is somewhat widely used and the extra attributes can ve better avoided.

Well, so we have fields for persistence and properties for behavior (databinding or something else), but there is the issue of waht accesibility should have those persistent fields.

Some friend of mine told me that all fields (public, private, etc) should be made persistent by default. Despite the fact that his idea have some sense, I don't like to make persistent by default all those private fields used for internal code (even the private fields exposed by our public properties), and I don't want to put non-persistent attributes over each private field I use.

I have thinked that maybe using protected fields as persistent by default should be a comprimising solution, but I'm not quite convinced.

Anyway, for build 1.0.0.7 I'm making this option configurable by entity, but defining the correct default is an important step in making Retina.NET more useful to us all.

So, here I am, asking for your opinions....

What do you think Retina.NET must consider by default as persistent?

Your comments are welcome!

Andrés.

4 Comments

  • Eric Newton said

    I have a suggestion... separate your 'behavior' types from the types that you want persisted. I believe Retina.NET was built to work with simpler types, and not ones that have a lot of behavior to them...

  • Andrés G Vettori said

    Well, that's not necessarily the case...
    Although you can certainly use that design pattern, I don't want to force developers using Retina.NET into that as I see the option of having business entities with rich behavior a better alternative.

    Anyway, if a developer wants to use that model is welcome also, but I think that these will not be the majority.

    Thanks for your comments,

    Andrés.

  • Andrés G Vettori said

    I was thinking about making the default behavior "nothing is persistent".
    Other OR/M using XML mapping files works like this, a not mapped field or attribute is non-persistent.

    In the future Retina.NET will include this feature and maybe changing the default now is a step in the right direction.

    Nothing will impede you to use other defaults if you don't want to make explicit attribute mapping, but that decission is up to the developer.

    What do you think?

    Andrés.

Comments have been disabled for this content.