Feb
26
ORM Thoughts Part II
February 26, 2009 | 1 Comment
Well, I have finally taken the plunge and started redevelopment of my Orders of Battle application in order to rewrite the data-tier of the application which is used by both Windows and Web Clients to interface with the back-end database, which is currently SQL Server.
As I mentioned below, the code was written several years ago and has stood the test of time well, but it is all written using .NET 1.0 and 1.1 functions. As a result, adding new screens or web pages is a real pain as I have to write a lot of code at all levels as well as new stored procedures.
I looked into using NHibernate, which is a very popular open-source ORM, and I even bought the new NHibernate in Action book recently published by Manning Publications. After reading the book, I eventually decided to not use NHibernate just yet but start with the new Entity Framework component of .NET Framework 3.5 SP1 instead.
I know that a lot of people criticised Microsoft for, apparently, dropping LINQ for SQL in favour of Entity Framework and that many have compared Entity Framework unfavourably with NHibernate.
I decided to use Entity Framework to get started because I wanted something simple to get me up and running as I am so new to developing ORM applications. It seems to provide everything I need right now and if and when I run into situations where it cannot help me then I will be in a better position to understand where NHibernate scores.
My main problem is that I have an existing application so I am not starting with an empty slate and I want to keep redevelopment to a minimum.
Secondly, I want to make my application database independent so that means that LINQ to SQL is not a contender because it can only be used with SQL Server.
Finally I like the idea of Entity Framework as I can use LINQ at all levels of the application; LINQ to Entities to query the Entities in the Model, LINQ to Objects to query Collections and Collection Classes and LINQ to XML where I need to read and write XML to MSMQ Queues.
So far, I have modified my application to use a DB Connection instead of a SQL Connection and written a new dll to handle both DB Connections and Entity Connections. This week, I started work writing a new data-tier DLL that will use the Entity Model to process all database operations using LINQ instead of using ADO.NET Datasets and TSQL Stored procedures.
What is interesting is that I have been able to maintain the basic structure of my middle tier classes which are mainly a set of collection and singleton POCO classes.
I am hoping to make some additional changes to the middle tier to reduce the amount of code and make things a bit more maintainable.
At the same time, I will have to make some changes to my home-grown replication code as that currently relies on TSQL stored procedures so I will have to rewrite that part of the application.
My goal is a slimmed down application in terms of code that will not use any TSQL stored procedures or functions which will allow me to add new screens or web pages to my applications much more quickly as there will no longer be so much back-end code to write.
Feb
18
Thoughts on Blogging
February 18, 2009 | Leave a Comment
Repeat visitors to this blog, assuming there are any, have probably noticed that the volume of posting has not been up to much in recent months, for which I apologise.
Actually, I do enjoy committing my thoughts to the ether, but the challenge is finding things to write about.
Originally, I had the idea that I would report on news items in technology areas that were of interest to me which was interesting as far as it went, but just repeating news items is not really that interesting although it is interesting what you learn by doing so. My problem is that I am interested in a lot of topics and maintaining focus on a wide range of subjects is quite a challenge and takes time that I do not always have.
I enjoy keeping up with the .NET world and the Mini-ITX world and I am still very interested in both topics.
On the Mini-ITX front, I currently have five different Mini-ITX machines that fulfill various roles for me, but the problem here is that they just keep ticking along and doing their job quietly and efficiently so I have not had much cause to write about them. My main development machine that I carry with me to Europe is a Mini-ITX box and I have absolutely nothing to complain about with it as it just does its job properly and steadfastly. If I had a need to build a new machine then I would talk about it on this blog.
On the .NET front, there are many developments that interest me, but at this point, I am focusing on learning new technologies in .NET 3.5 as I hope to start redeveloping some of my applications very soon to take advantage of some of the new features in .NET 3.5 very soon and I will of course be writing about that.
I fully intend to keep blogging but this blog will evolve over time. I will of course continue to discuss technical issues and challenges that I face designing, developing and upgrading my Order of Battle website; much of which has a wider relevance in that many companies and projects face similar challenges.
Feb
18
Apology!!
February 18, 2009 | Leave a Comment
I just wanted to write a brief apology to anyone who may have been foolhardy enough to leave a comment and was wondering when it might appear!
Unfortunately, this fine blog has been overwhelmed by spam so any worthwhile or constructive comments have been literally drowned in an absolute flood of useless drock.
At the time of writing, I have something like 18000 comments sitting in my in-tray, all but a few of which are absolute garbage.
I hope to soon spend a bit of time upgrading the version of Word Press that I use and installing a better spam filter but at this point I am a bit overwehlmed.
Please accept my apologies for this situation and I hope to recover any constructive comments soon.
Feb
2
ORM Thoughts
February 2, 2009 | Leave a Comment
I have no prior experience with ORM (Object-Relational Mapping) concepts thus far in my career, so a lot of the technologies and tools that have become well-known and recognised in this area are very new to me.
That said, as someone with a lot of experience (in my pre-Siebel days) in database design and entity-modelling, ORM is something that I have always had a passing interest in and a desire to learn more about.
My first experience with the challenge of mapping Relational Tables to Classes came about 10 years ago when I read the book VB6 Objects by Rockford Lhotka and I used a modifed version of his methodology to design the data and business layers of my Orders of Battle applications which I wrote using the .NET Framework 1.1 in about 2000-2001. Lhotka’s methodology has since been rewritten and is now called the CSLA.
My application uses ADO.NET Datasets and POCO classes and is very-database specific in that the ADO.NET objects used are specifically for SQL Server only.
The middle-tier is built around Collection Classes which manage individual Singleton Classes which map to a specific database table. Every record is always retrieved and manipulated via a collection.
The data-tier is dedicated to creating and managing datasets and parameters and uses TSQL Stored procedures to manage all Selects, Inserts etc. Depending on the data structure of the tables involved, a single data-tier class can manage a single database table or several database tables.
The end result is a lot of code, much of it of the “plumbing” variety, and I now have to cope with over a hundred stored procedures.
This means that adding new functionality to the web site or the windows data-input application is a real chore with lots of code to add or change all the way down the line.
On the whole, the design of my classes and tiers has stood the test of time well, but looking at many of the new technologies out there, I now believe that the time has finally arrived to rewrite the data-tier.
My goal is to develop a data-layer that is database-independent and does not require the use of stored procedures. However it has to have an interface that is as compatible as possible with my existing middle-tier and it should represent the existing structure of my database while at the same time giving me the possibility of gradually modifying it in the future to represent a more conceptual view of the database.
With regard to the middle-tier, while changes will have to be made in terms of removing references to ADO.NET objects etc, I want to keep all changes to a minimum for now.
Needless to say, I do not want to have to make any changes to the presentation layers at all.
I am still looking at different tools and I will write about that topic soon.

