How NHibernate forced me to OO design

time to read 1 min | 120 words

At some point of my code, I had this method.


Remember, this is spike code, so I didn't care for breaking things like encapsulation or getting ugly code. In essence, the code above is breaking encapsulation and stomps all over DRY and Liskov substitution principle.

It worked for a while, then it stopped. The reason that it stopped is that I started passing it lazy instances. And a lazy instance is a proxy, which is neither an ImageItem or HtmlItem. So now ContentItem has the following:


As an aside, notice the RecordApperances method. That is the absolute top of Ask, don't tell.