PrimeDigit – A Design Blog by Will Shaver

August 28, 2008

Multi Monitor Wallpapers at FrozenTear.com

Filed under: Other — Will @ 12:06 am

I’ve put up some of my multi monitor wallpapers at frozentear.com. If you develop on a 3200×1200 screen you might want to check this out. No promises, I’m a coder not an artist. :)

August 26, 2008

ISession Extension for Saving Multiple Objects

Filed under: c#,NHibernate — Will @ 3:36 pm

Incredibly simple, but quite useful:

        public static void Save(this ISession session, params object [] entities)
        {
            foreach (var o in entities)
            {
                session.Save(o);
            }
        }

You can use it like:

session.Save(a,b,c,d,….);

with a list of objects of any type. Useful for unit testing where you want to save multiple items at once.

[Update]

Probably should call it something other than Save, such as SaveAll or SaveList because if you only pass two items to the overload it calls the standard Save(object, int id) version. :(

August 20, 2008

Abstract Class Mappings

Filed under: Uncategorized — Will @ 12:05 pm

If you’re running into this error in NHibernate:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Attempting to parse a null value into an sql string.

Examine your mappings for abstract classes that aren’t implemented, or classes that are marked as abstract in the mappings but not in the c# file. I was refactoring out some abstract classes in the middle and forgot to delete the abstract=”true” line in the mapping.

August 5, 2008

Death to Foo and Bar

Filed under: Uncategorized — Will @ 5:49 pm

I’ve had it with Foo and Bar. They are right out. For too long we programmers have put up with these sorry excuses for example classes in documentation, lectures, examples, and now that TDD is all the rage, tests.

There is no standard for the relationship of Foo and Bar.

Standards in examples and relationships are full of time-saving goodness. Take for example the Northwind database. Recently there’s been a big push for replacing Northwind with some other database standard. One of the chief arguments against the “Not Northwind” mafia are the magic words, “I’m using Northwind for my database”. *Poof* everyone in the audience knows the relationships inherent in the system.

But Foo and Bar have no default relationship. In the NHibernate project there are 8 different Foo classes, 2 Bars, and 1 FooBar. One of those is actually even in the NHibernate.DomainModel namespace, most of the remainder are in the SpecificTest folder. Different developers have created tests relying on Foo and Bar, and when debugging these tests I have no idea what the properties, entities, or relationships should be.

A sampling of different properties shows that some Foos have Descriptions, while others have Names, Words, Numbers. Some have other Foo as children, while others have Bar as children. Sometimes a FooBar will have a Foo or Bar property….

Enough!

Please, if you submit a patch to an Open Source project… or any project for that matter, don’t use Foo or Bar. Use People and Pets, Cities and Houses, Sales Orders and Sales Line Items, Customers and Orders… any number of obvious relationships that readers won’t need to review the class in order to understand. Foo and Bar slow the reader down… even if you’re the one that wrote it.

NHibernate Developer

Filed under: Uncategorized — Will @ 5:39 pm

W00t! I’ve been accepted as a developer of NHibernate. I’m looking forward to helping this project move along as I discover things that I can fix…

Powered by WordPress