Wednesday, July 3, 2013

Jumping into Micro ORM

I've known about (and worked with multiple forms of) standard Object Relationship Management frameworks in the past (e.g., Hibernate - with and without Spring wrappers - for Java, nHibernate for .NET, SQLAlchemy for Python), but usually only on fairly big enterprise systems that justified the setup and overhead.

But what if you want something simple, small, fast (performance and development), and portable? More on that in a minute...

Recently I've needed to track a medium-sized relational data set that is stored in (ugh) a few hundred different XML files. This is data that needs to be queried quickly, updated automatically, and viewed using some kind of light-ish weight GUI.

So the cocktail napkin sketch of the data flow looks like this:

XML Data -> (deserialized) -> domain objects --> (stored) -> DB

The data is only manipulated once it's in the DB, then back out again to be used with the 3rd party system that needs the data in XML.

DB -> (queried) -> domain objects -> (serialized) --> XML Data

My experiences with the various flavors of Hibernate are my comfort zone. But this seems like a good time to experiment with a Micro ORM. I don't have a lot (or really any) multi-phase commits or concurrent transactions to worry about, no database clusters, no complex legacy data structures, none of the other stuff you tend to need to worry about in a Very Big Enterprise App(TM).

I already have a fair amount of the domain objects representing the data model in an existing C# .NET project, so here's what attempt #1 will look like:

  • A fairly bare-bones (for now) C#.NET v4.0 winforms app that will
    • house the library of domain objects, 
    • do the serialization/deserialization to XML,
    • perform unit tests,
    • interact with the Micro ORM library
  • A Micro ORM Library
    • PetaPoco for now, we'll see how it works!
  • A database
    • Sqlite for now, we'll see how well it plays with PetaPoco and/or other Micro ORMs.

The next post will be initial setup, maybe some code snippets, and a thumbs up or down whether I can quickly and easily test storing and querying with the stack I've chosen.

Stay tuned...

No comments:

Post a Comment