The Inversion of Control  (a.k.a. The Hollywood Principle) & ORM Panacea

Inversion of Control (IoC) is old news for the Java community but it is the latest and greatest panacea for the .NET world.

Inversion of Control actually first came to light way back in the late ’80’s when it was mentioned in Johnson & Foot’s paper Designing Reusable Classes.  I’m pretty sure that I was the second person to mention it, I can remember using Object Oriented Programming, more specifically Polymorphism a long time ago.  But in reality, the concept is vaguely similar but not quite the same.  There is no doubt that IoC, ORM, and Repository Pattern are pretty hot subjects in the .NET community lately, and the excitement is well deserved, in my humble opinion anyway.

What is Inversion of Control (aka The Hollywood Principle)?

I’m going to try and put this in my own words because many of the definitions on the web come from persons who tend to be a little too into theory, you know the guys that write code for museums instead of the real-world.  (grin)   Inversion of Control is a framework rather than a class library.  In object oriented design (namely Polymorphism) you typically determine which class you will be using, instantiate it and call a set of functions.  Inversion of Control embodies more of an abstract design with more behavior built in, the framework rather than the program (UI) determine the coordinating, sequencing and application activity and in turn provides the “class” to you.  (IoC is also known as the  “Hollywood Principle” meaning “Don’t call us, we’ll call you”)

What Is Object-Relational Mapping?

Object-Relational Mapping (ORM) is the concept of mapping an application’s business objects (POCO’s) to RDBMS tables so that data can be accessed and updated entirely through the object model of the application.  This is an almost perfect implementation of separation of concerns.

ORM .NET Silverlight 4 PowerBuilderOn the opposite end of the scale, many popular controls in .NET allow you simply to bind data directly from the database to your controls.   It helps programmers to quickly set up and create simple applications with .NET but can make for a difficult to maintain application down the road after the data model has changed a few times or the application starts growing.  New business logic is added over time and makes things much more complicated. The database becomes bigger and more complex with each new requirement and it soon starts to take on a life of its own.

Significant players in the ORM arena for .NET

1. Castle Windsor Framework –

Inversion of Control (IoC) and Dependency Injection (DI) are two related practices in software development which are known to lead to higher testability and maintainability of software products.   The Castle Project framework leverages IoC and DI.

2. DataObjects.Net

DataObjects is a not an open-source solution, but is a well respected ORM and business logic layer for .NET projects.

3. Linq to SQL

Linq to SQL ships with Visual Studio 2010 and is a respectable player in the ORM arena.

4. nHibernate

nHibernate is another popular ORM for the .NET platform.   It is a port of the popular Hibernate from Java.

5. BLToolkit

Business Logic Toolkit for .NET is written in C# and compatible with .NET Frameworks 3.5, 4.0, Silverlight 4, and Mono.  Reports from ORMbattle.net show BLToolkit being a leader in performance over all other ORM’s

We’ve talked about how Object Relational Models and Inversion of Controls  and how they can isolate the data access layer very effectively.  They are concepts that are worthy of the hype.  I hope that this overview has helped you better understand what will likely become very common in the corporate IT world soon.

Sincerely,

Rich (aka DisplacedGuy)

5 Responses

  1. The guidelines you contributed here are really precious. Rrt had been such an enjoyable surprise to get that waiting for me as i woke up today. They are constantly to the point and easy to learn. Thank you for the useful ideas you have shared in this article.

Leave a Reply to Barry Fester Cancel reply

Your email address will not be published. Required fields are marked *