Category Archives: AjObjects

Working on AjObjects: in-memory document/Dynamic object Base

At the beginning of the century, I began to write three . NET projects: AjStorm (Simple Tool for Object Relational Mapping), AjGenesis (Code generation) and AjObjects (in-memory objects with queries). Only the second project is alive. But I learnt about reflection in the three projects, how to implement simple queries in AjObjects (now, we have LINQ in .NET). You can see some prehistoric code at:

And, after using PHP for years, I implemented dynamic objects in AjBasic, internal language of AjGenesis. Two years ago, I added dynamic objects to AjSharp as one of its base ideas. In AjBasic and AjSharp you can write:

abel.Name = "Abel"
abel.Age = 600
abel.Father.Name = "Adam"
abel.Father.Age = 800

without previous definition of the object and its properties. In AjSharp you write:

abel.Name = "Abel";
abel.Age = 600;
abel.Father.Name = "Adam";
abel.Father.Age = 800;

More recent info at:

AjSharp: Dynamic Classes and Objects

AjSharp posts

Most language over .NET and Java VMs now are recognizing the power of dynamic features (.NET 4.x have ExpandoObjects, I guess they was born with DLR Dynamic Language Runtime, see? dynamic keyword is the key :-).

I was playing with in-memory objects for a while, recently I wrote some experiment in AjTwitter. And I play with a more “relational” implementation in AjBase. Both projects are inside the trunk of:

Impressed by the NoSQL movement, I dediced to push the envelop of my spare time, and as weekend code kata, I wrote the skeleton and base of something inspired by MongoDB, what is known as document-oriented database. My project is written in C#. You can see the code in the mentioned AjCodeKatas Google Project, with name AjObjects.

I defined a BasicObject (like BasicDBObject in Java driver for MongoDB):

The BasicObject can be filled using default indexed property:

BasicObject newobj = new BasicObject();
newobj["Age"] = 800;
newobj["Name"] = "Adam";

or by a factory method:

BasicObject newobj = BasicObject.CreateObject("Name", "Adam", "Age", 800);

Collection is the container for BasicObjects:

You can insert, delete objects. A new inserted object obtains a Guid. You can retrieve an object via its Guid. There is a Find(Predicate<BasicObject>) method to return a Cursor over basic objects that makes the predicate true:

The method Update(Predicate<BasicObject>,Action<BasicObject>) applies the action to the select objects in the collection.

I should work more on:

Concurrency: Actually, Collection has locks around its method code. Cursor obtains a copy of the current list of object (copy of the list, not the objects). While using the cursor, you can update the collection, without changing the cursor content (list and objects).

Persistence: There is a BasicObjectSerializer, to improve: more basic types, I need a BasicList implementation, too.

Distribution: I plan to have many host with replicas, with eventual consistency (Hmmm.. I should review the current terminology).

Keep tuned!

Angel “Java” Lopez