As mentioned before I’m starting the (re)design for our upcoming major release. This is an exciting time because we will be using a couple of new techniques here. One of which is DevExpress’ XPO, eXpress Persistent Objects.
I had done some tests before, but now the real work starts I find that typing the object model rather than drawing is a big down side for XPO. I’m afraid that in this day and age you really need a visual modeller.
That said, I’ve bitten the bullet and started the design. I took that a bit light-hearted and thought I would have done that in a couple of hours. You know, thinking: “what do I need to do different compared to our current object model? It’s all been done and we know exactly what we want”.
Not, I can tell you. I find that rethinking over the object model brings up a couple of flaws that only become apparent if you don’t think of databases anymore. If you think in objects only, you experience another kind of designing entirely. I’ve been object modelling for quite some time, but doing it for real while reverse engineering a larger model is quite different to what I did before.
But, the reason I started this post is I wanted to share my first unit test with you. I was looking in the XPO software for a ‘model checker’. Since XPO is about storing data, and you need to specify the object relations using ‘code’, I suspected I might have mistyped something somewhere and wanted to check of all was well.
That’s quite easily done, using a unit test. It’s ever so simple, but helps you to check the object model while designing. Just make the test project your current project, add a reference to the assembly that holds your XPO model (everyone puts that in a separate assembly, right?) and run the test when you want to check your model.
This is the single line test that has been my friend for today:
[TestMethod]
public void CheckValidityOfDicationary()
{
new ReflectionDictionary().GetDataStoreSchema(typeof(S7XPO_Base).Assembly);
}
Replace S7XPO_Base with any of your persistent classes and you’re off. If there is an error, an exception is thrown and your test will fail, telling you exactly where the problem is.
Hope this is of use to anyone. It certainly helped me a lot.
Bye,
Bart
3 comments:
I think it's to pity choose XPO. I've worked with XPO on a large scale project two years a go and I found it unpleasant to work with. Perhaps a lot has changed over the last few years, but I found it too database centric and it needed the object definition stored in a database table. Why did you choose XPO over say NHibernate, LLBLGen or Entity Framework?
To me, the choice really was between the Entity Framework and XPO. For now, I've chosen to use XPO, but if it turns out not to be the right choice, I will change.
I chose XPO primarly because of the confidence I have in Devexpress. For now, I look upon our current activities as an enhanced test of the chosen technologies. If something fails, it will go out of the window.
Thanks for your suggestions.
>> To me, the choice really was between
>> the Entity Framework and XPO.
EF is maturing really quickly. While I hate the current v1 release of EF I have great faith in what EF will be like with when it ships with .NET 4.0. Especially the T4 templates that come with EF and the possibility to tweak those templates (i.e. there’s a T4 for POCO/IPOCO support).
Switching O/RM tools later on in the project will be a lot of work, even when you architected it correctly (otherwise it is probably impossible). But switching to EF v2 next year could be worth the trouble :-). Good or not, EF will become the de facto standard O/RM tool for the .NET framework. Other commercial O/RM venders know this. Frans Bouma (the man behind LLBLGen Pro) is focusing on tooling support. A smart move. Currently his tools are designed solely for his LLBLGen O/RM framework, but in the future his tools will support other O/RM tools, like EF. This is great, because now he can sell power tools for EF.
>> If you think in objects only, you experience
>> another kind of designing entirely.
I agree. I must say it was quite a change for me switching from a database design mindset to an object model mindset. I haven't looked back since :-). Only the mapping back to the database is a problem when your O/RM tool doesn’t support mapping anything else than a one-to-one mapping. How does XPO currently handle this? I don’t think this was possible when I used XPO a few years back.
Post a Comment