Code Elegance

Archive for January, 2010

My presentation on Mock Objects (UgiALT.NET Conf)

Here you can find the slides of the presentation that I did last week at the Italian ALT.NET Conference about mock objects: http://www.slideshare.net/emadb/mocking-2998380

(they are in Italian, sorry)

No comments

UgiALT.NET V Conference

Last Saturday there was the winter edition of the Italian ALT.NET conference. The 5th edition. It was a great day, with more the 130 participants, 20 sessions about DDD, BDD, TDD, SQL and NO-SQL Database, REST, Dynamic Languages, agility, Refactoring, #Architecture, Mock Objects, HTML5, iPhone, Monotouch, JQuery and many more themes.

One of the aspects that characterize the ALT.NET conference is the high level of the sessions (there was no entry level sessions) and the high level of the attendees. In every session that I followed there were always a discussion on the topic and the speaker leaves the attendees speak and tell their opinion so that everybody can learn from the others. Most discussion has continued in the hall and in the others rooms available for open spaces.

For me, Simone and Claudio it was an hard day dealing with the organization, but most attendees help us when needed, so my thanks goes to all the people that help us yesterday.

Other thanks to the speakers, most of them came from other cities, Hadi and Chris from another country. Thanks for coming.

Finally the donors, this year we collected money from donors that gave us something to cover the costs. It went great. With the donations we cover all the costs and we have more money for the next edition (june? july?).

I’m really happy, in 3 year we built a .NET community that is not tied to the .NET framework but is interested in all the technologies that helps the developer to build better software.

Here are some photos: http://picasaweb.google.com/diegoguidi/Milano23012010

In the next days we will publish the slides and demos from the presentations.

 

Technorati Tags: ,,
No comments

Experiments with MongoDb

During the Xmas holidays I found the time to have a look at MongoDb a Document oriented Database where the schema is based on JSON.

I downloaded the binaries and the C# Driver and I started some experiments.

The setup-time is minimal, the server is a console application that remain ready on a certain port:

D:\mongodb-win32-x86_64-1.2.1\bin>mongod.exe --dbpath ./data

Tue Jan 05 19:16:20 Mongo DB : starting : pid = 0 port = 27017 dbpath = ./data m
aster = 0 slave = 0  64-bit
Tue Jan 05 19:16:20 db version v1.2.1, pdfile version 4.5
Tue Jan 05 19:16:20 git version: 45992de574979343f34fdfe96b069d5d1eff0182
Tue Jan 05 19:16:20 sys info: windows (6, 0, 6002, 2, 'Service Pack 2') BOOST_LI
B_VERSION=1_39
Tue Jan 05 19:16:20 waiting for connections on port 27017

Above I simply specified the data folder even if there are a lot of parameters you can set.

The first sample that I write is this:

Mongo mongo = new Mongo();
mongo.Connect();
Database db = mongo.getDB("MyTestDb");
IMongoCollection posts = db.GetCollection("Persons");

Document doc = new Document();
doc["Name"] = "Emanele";
doc["Surname"] = "DelBono";
posts.Insert(doc);


Document example = new Document();
example["Name"] = "Emanuele";
ICursor cursor = posts.Find(example);

foreach (Document document in cursor.Documents)
{
  Console.WriteLine(document.ToString());
}

The first block is needed to open the “connection” to the database and to select with collection to work with.

Then I create a new Document and I fill in the key value pairs. The Document class is a dictionary that keep the document data and in JSON format and is converted BSON by the driver when the insert instruction get called.

The third block is a query to the database. I created a new document with a property name and the needed value, the Find method get a cursor from the database with all the matching document (i.e. all the persons whose name is Emanuele).

The power is in the storage and query method. You can create a complex document (with sub-documents, collection and so on) and store like a simple document.

This is a very first basic example on how to setup and run a micro-application on MongoDb, I’m now working on an extension to transform domain model objects in Document hierarchies so I can avoid the manual mapping from a Person class to the Document class.

Maybe in a next post I’ll talk more about that.

6 comments