Dot Net Tricks

Articles about .NET, ASP.NET, C#, Object Oriented Programming and Agile Methodologies
Welcome to Dot Net Tricks Sign in | Join | Help
in Search

Software Theosophy

Found some good code today

I'm hoping this won't offend any of you out there, but most of us developers write crappy code.  I'm not fully sure why this is, but even if the database isn't a steaming pile of horse poo, the code usually is.  There's often a lot of code duplication, methods and property names that don't make much sense, large, "god-like" classes, massive amounts of nested "if" or "case" statements, etc.

I'm not even getting into ORMs, design patterns, DI, Loose Coupling and High Cohesion, Unit Tests or anything like that.  Many programmers don't follow basic, good, structured programming tactics.  You have to walk before you can run but it often seems like a lot of programmers, even those with 10+ years of experience are still crawling.  My screaming about database normalization at Telerik is an example of this, and we just ran into another vendor with few relationships in their database, zero constraints and a whole lot of duplication.  Fortunately we do not have their source code (although I hear its in VB.NET.)

But enough of that.  Today I found some REALLY GOOD CODE.  Its not perfect--no code is--but its really high quality.  It comes from a little product that always has a soft spot in my heart, the Wilson O/R Mapper.  This was the first ORM I really liked.  You should pull it down and take a look at the source code. It used to be a commercial product but Paul Wilson open sourced it some time ago.

Even though NHibernate is our standard right now and does a lot of great things, I've been toying.with the idea of writing a new ORM or extending an existing one.  NHibernate has a lot of complexity, and as Robert pointed out to me, its difficult to get working with a remoting or WCF type architecture for smart clients.  NHibernate also has a lot of other warts, including a sometimes ugly API that is dated and based on its java sibling, complex mappings, surprises when it comes to bidirectional relationships (those of you having to create a method that looks something like this: Customer.AddOrder(order) know what i'm talking about...) and other nastiness.  Its probably one of the best ORMs out there but by no means perfect.  EF still isn't out as far as I know and has a lot of growing up to do.  So i've been thinking of working on my own ORM, without starting from scratch.

I could try extending the NHibernate codebase, but its plain ugly.  Many of the failings I just mentioned above live within the NHibernate source.  I'm not sure if this is NHibernate showing its age or what, but I'm afraid to try to alter anything within it.  Everything is big, complex and hairy.

So imagine my surprise when I downloaded the latest source code to Wilson ORM.  Small, concise methods.  Highly cohesive classes.  Appropriately named classes, methods and properties.  Good use of interfaces.  Minimal duplication.  Everything is broken up into logical chunks.   In short: "GOOD CODE".  To be fair, Wilson doesn't do everything that NHibernate or some of the other mappers do, but even still, the codebase and API simplicity is impressive.  Its so easy to be bitter and jaded about bad programming, so I thought it appropriate to say "well done" to Paul Wilson and the other developers that have worked on it.

I encourage you to download the thing just as a learning experience. 
Published Sunday, December 21, 2008 4:01 PM by Fregas
Filed Under: , , , ,
Anonymous comments are disabled

About Fregas

Craig is currently the Lead Developer in Fort Worth, Texas for Enilon Group, a web development firm. He has been programming since 3rd grade (using the Commodoore PET) and professionally for the past 7 years. He has written several articles for ASPToday.com and co-authored the book "Beginning Web Programming using VB.NET and Visual Studio .NET" Currently, his favorite programming language is C#, but he has programmed in Visual Basic, T-SQL, Ruby, ColdFusion, ASP 3.0/VBScript, ASP.NET, Javascript, Java and even Pascal. Besides programming, Craig is best known for his cooking and his somewhat offbeat sense of humor.

This Blog

Post Calendar

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Syndication

Powered by Community Server, by Telligent Systems