Review of .NET

I read an article in some rag called The Register. I got the feeling this is a British newspaper. But I am not sure. The article reviewed the rise of .NET and whether it achieved Microsoft's goals. I thought I would discuss some of the point brought up by the article.

It has been almost ten years since .NET first came out. This was a major shift in the Microsoft Windows platform. We were coming off Active X controls and the MFC framework.

.NET brought the common language runtime, as well as the new C# programming language. The base protocol used was XML. The goal was to combat Java from Sun Microsystems.

If you look at the programming language landscape today, C# is a success. A lot of people use it. More importantly, there are many jobs which require C# experience. One thing that is a bit disturbing is that Microsoft it not eating their own dog food. They don't seem to be using .NET for developing their own products.

The article concludes that .NET is positioned for the business app segment. This is the industry I work in. So it is a shame that I am not hot on the latest technologies in .NET. Time to study up.

Entity Framework

The ADO.NET Entity Framework (EF) is an existing object relational mapper (ORM). Unfortunately the version that came out with the .NET Framework version 3.5 got a lot of bad press with developers. Microsoft is going to release the next generation which they are calling EF4.

EF maps .NET objects to the database. The idea is that your database can change, and the EF mapper can protect your application from having to deal with these changes. EF is a competitor of the NHibernate product. NHibernate is an open source alternative. It is a surprisingly good implementation of an ORM.

Developers can use EF4 to help code web services. While EF4 may still not live up to the NHibernate standard, Microsoft is positioning EF4 as the main ORM.

ASP.NET 4.0

Microsoft has two main frameworks to do web development. The older one is the ASP.NET web forms framework. The newer is ASP.NET MVC. Let’s start with the older. The latest changes to ASP.NET web forms makes it easy for HTML to be styled using CSS. It also changes how easy it is to control the identifiers created by the framework.

Now let’s talk a little bit about ASP.NET MVC which is new for version 4.0. This framework in general has been designed to make it easy to test web apps. Big projects can be broken into pieces called areas. The developer divides the project up logically into these areas.

This is just a taste of new things in ASP.NET version 4.0. I am getting into web development myself. When I use the Microsoft tools, I might get heavy into ASP.NET. At that time I will continue to share my findings.

Introducing NHibernate

Hibernate is a popular Object Relational Mapper in the Java world. Now there is a port for .NET called NHibernate. Like Hibernate, NHibernate maps .NET objects to the database. It is licensed under the LGPL. In other words, it is free. This is becoming a popular method for .NET web developers to interface with a database.

NHibernate works just like normal desktop application persistence technology. As such, there is a tendency to have one global session for your whole application. However .NET experts recommend that you keep session lifetimes down at the transaction level. This will cut down on memory leaks as well as other problems.

Note that the NHibernate session is not exactly the same as a database connection. This session is managed by the NHibernate framework. Actual database connections may come and go with one NHibernate session.

Here is a peculiar fact with NHibernate. You have to make your class members virtual. That applies to all members. You should also be aware that the time for NHibernate to start up is long. Yes I know. That is no fun. So kick the NHibernate stuff off to a separate worker thread. Just recognize that NHibernate is not thread safe in the sense that two threads cannot access the same NHibernate session at the same time.

That’s all for now. Next time I want to revisit ASP.NET 4.0.

Object Relational Mapping

Object Relational Mappers (OR/Ms) seem to be a hot topic these days. The mappers connect object and database models. The actual mappings are defined in XML format. Microsoft currently has two OR/Ms available. The first is LINQ to SQL. The other and newer one is ADO.NET Entity Framework.

There are some difficulties with both of these OR/Ms. The tools generate objects with names that match the corresponding database entities. This is not what developers always want. A further complication is when the database names change after the object model is generated.

If you use LINQ to SQL, and the database name changes, you must get rid of the previously generated object entities. Then you must regenerate them to match the database updates. That is a clunky mechanism. In the past, my team has encountered a lot of pain to manually update object models when we used other OR/Ms.

I plan to write about this topic more deeply in the future.