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

  • Introducing SNARF


    I'm now part of two open source project, although this one I really want to be hands off.  So if anyone is interested in taking it over, feel free.  Here's a description from google code:

    SNARF (Simple, Nhibernate, ActiveRecord Framework)

    This is a C# .NET class library and set of Codesmith templates for generating code using the ActiveRecord pattern.  It uses NHibernate for the underlying persistence in a fashion similar to Castle ActiveRecord.  However, it differs in that the database generates the classes as well as xml mappings and does not use attributes.  It does make some assumptions about your database schema. 

    Its been used in production, but has only been tested with Sql Server 2000 and 2005.

    Snarf is good for small-medium size projects because we feel thats also what the ActiveRecord pattern is good for.  However, should you need to switch to something heavier (DataMapper/Repository) you have the full power of NHibernate at your disposal.


    I released SNARF on google code.  Its something I built in my spare time for work, but since I no longer use the ActiveRecord pattern for larger projects and want to concentrate more on upgrading/rewriting WilsonORM, i'm releasing snarf to the wild. 

    You can find Snarf here:
    http://snarf.googlecode.com/

  • I'm part of an open source project!

    I'm contributing to the Wilson O/R Mapper project which is now open source and on google code.  I'm adding fluent mappings for WORM in the same manner as Fluent NHibernate.  Exciting stuff!

    http://code.google.com/p/wilsonormapper/source/browse/#svn/branches/FluentMappings/Wilson.ORMapper/FluentMappings



  • 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. 

This Blog

Post Calendar

<September 2010>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

Syndication

Powered by Community Server, by Telligent Systems