Is my idea for an object persistence library useful?
Asked Answered
L

4

6

First, I apologize if this is not an appropriate venue to ask this question, but I wasn't really sure where else to get input from.

I have created an early version of a .NET object persistence library. Its features are:

  • A very simple interface for persistence of POCOs.
  • The main thing: support for just about every conceivable storage medium. This would be everything from plain text files on the local filesystem, to embedded systems like SQLite, any standard SQL server (MySQL, postgres, Oracle, SQL Server, whatever), to various NoSQL databases (Mongo, Couch, Redis, whatever). Drivers could be written for nearly anything, so for instance you could fairly easily write a driver where the actual backing store could be a web-service.

When I first had this idea I was convinced it was totally awesome. I quickly created an initial prototype. Now, I'm at the 'hard part' where I am debating issues like connection pooling, thread safety, and debating whether to try to support IQueryable for LINQ, etc. And I'm taking a harder look at whether it is worthwhile to develop this library beyond my own requirements for it.


Here is a basic example of usage:

var to1 = new TestObject { id = "fignewton", number = 100, FruitType = FruitType.Apple };

ObjectStore db = new SQLiteObjectStore("d:/objstore.sqlite");
db.Write(to1);
var readback = db.Read<TestObject>("fignewton");

var readmultiple = db.ReadObjects<TestObject>(collectionOfKeys);

The querying interface that works right now looks like:

var appleQuery = new Query<TestObject>().Eq("FruitType", FruitType.Apple).Gt("number",50);
var results = db.Find<TestObject>(appleQuery); 

I am also working on an alternative query interface that lets you just pass in something very like a SQL WHERE clause. And obviously, in the NET world it would be great to support IQueryable / expression trees.

Because the library supports many storage mediums with disparate capabilities, it uses attributes to help the system make the best use of each driver.

[TableName("AttributeTest")]
[CompositeIndex("AutoProperty","CreatedOn")]
public class ComplexTypesObject
{
    [Id]
    public string id;

    [QueryableIndexed]
    public FruitType FruitType;

    public SimpleTypesObject EmbeddedObject;
    public string[] Array;
    public int AutoProperty { get; set; }
    public DateTime CreatedOn = DateTime.Now;
}

All of the attributes are optional, and are basically all about performance. In a simple case you don't need any of them.

In a SQL environment, the system will by default take care of creating tables and indexes for you, though there is a DbaSafe option that will prevent the system from executing DDLs.

It is also fun to be able to migrate your data from, say, a SQL engine to MongoDB in one line of code. Or to a zip file. And back again.

OK, The Question:

The root question is "Is this useful?" Is it worth taking the time to really polish, make thread-safe or connection pooled, write a better query interface, and upload somewhere?

  • Is there another library already out there that already does something like this, NAMELY, providing a single interface that works across multiple data sources (beyond just different varieties of SQL)?
  • Is it solving a problem that needs to be solved, or has someone else already solved it better?
  • If I proceed, how do you go about trying to make your project visible?

Obviously this isn't a replacement for ORMs (and it can co-exist with ORMs, and coexist with your traditional SQL server). I guess its main use cases are for simple persistence where an ORM is overkill, or for NoSQL type scenarios and where a document-store type interface is preferable.

Limpet answered 30/6, 2010 at 1:6 Comment(2)
I get the feeling, and correct me if I'm wrong, but that you're re-inventing the wheel. What it seems as if you're talking about is having runtime type checks for a specified object (Type) with different member properties that you need to access. This facility already exists with the inclusion of var and of LINQ in C# 3.0.Gloucester
The concern that I was re-inventing the wheel is definitely what prompted this question. I'm still not completely convinced that I am, though. I think there's still a domain for which this approach is better suited than the options that are currently available. How big that domain is, is harder to say.Limpet
G
4

My advice: Write it for your own requirements and then open-source it. You'll soon find out if there's a market for it. And, as a bonus, you'll find that other people will tell you which bits need polishing; there's a very high chance they'll polish it for you.

Glutton answered 30/6, 2010 at 1:12 Comment(0)
D
2

Ben, I think it's awesome. At the very least post it to CodePlex and share with the rest of the world. I'm quite sure there are developers out there who can use an object persistence framework (or help polish it up).

Dendroid answered 30/6, 2010 at 1:24 Comment(0)
F
1

For what its worth I think its a great idea.

But more importantly, you've chosen a project (in my opinion) that will undoubtedly improve your code construction and design chops. It is often quite difficult to find projects that both add value while improving your skills.

At least complete it to your initial requirents and then open source it. Anything after that it is a bonus!

Filterable answered 30/6, 2010 at 2:4 Comment(1)
Yep, I absolutely have learned a lot working on this project, and surely will learn more if I continue on with features like expression trees. I agree, it's rare to find projects that are both educational and (hopefully) useful.Limpet
R
1

While I think the idea is intriguing, and could be useful, I am not sure what long-term value it may hold. Given the considerable advances with EF v4 recently, including things like Code-Only, true POCO support, etc. achieving what you are talking about is actually not that difficult with EF. I am a true believer in Code-Only these days, as it is simple, powerful, and best of all, compile-time checked.

The idea about supporting any kind of data store is intriguing, and something that is worth looking into. However, I think it might be more useful, and reach a considerably broader audience, if you implemented store providers for EF v4, rather than trying to reinvent the wheel that Microsoft has now spent years on. Small projects more often than not grow...and things like pooling, thread safety, LINQ/IQueryable support, etc. become more important...little by little, over time.

By developing EF data store providers for things like SqLite, MongoDB, Xml files or flat files, etc. you add to the capabilities of an existing, familiar, accessible framework, without requiring people to learn an additional one.

Recede answered 30/6, 2010 at 2:16 Comment(1)
Yes, this is something I'll look into. To be honest, I'm barely aware of EF. At a glance it basically seemed like any other SQL ORM. I will definitely do some research on it. Linq-to-SQL seemed promising and had it not been for the tie to SQL Server I would probably have been content with that. I agree completely about code-only, which is why a lot of SQL ORMs bother me (especially on platforms without LINQ) and part of what inspired this project.Limpet

© 2022 - 2024 — McMap. All rights reserved.