MVP (a.k.a MVC) in VB.NET

Model-view-controller is an old, old, old but very good idea. It encourages the separation of model, presentation and control from each other. It’s used in so many places I can’t name them but frameworks like: Struts and Ruby-On-Rails actually enforce it.

For a long time it seems to me that Microsoft has lagged behind in allowing us to use this idea. Their once flagship product, Visual Basic 6, makes it almost impossible to write good MVC code. First of all, in VB6 there is no real inheritance which makes writing good models difficult. Secondly, if those models should contain any items that generate events then those items can not be defined in a class module and must be made public. Sure you can simulate and work-around these things by various means but in the end you will just be fighting the language. And that is never good.

So it’s good to see VB.NET, or .NET 2.0 to be precise, not only has excellent object support but a mechanism that can be used for MVC is actually built into the language. Continue reading “MVP (a.k.a MVC) in VB.NET”

if they’re the same thing do nothing, if they’re different things do something

So I’m inspired by this post at the Daily WTF. The problem happens quite a lot in Java and I’m sure I’ve come across it myself at least once.

The central issue is, how do you safely (i.e. no NPE!) and cleanly compare two values where both could be null?

It’s only a small challenge, I grant you, but the code sample they have at WTF will return false if two Boolean’s have the same value, including nulls. Continue reading “if they’re the same thing do nothing, if they’re different things do something”

refused by my own credit scoring system!

My wife and I recently purchased a new car. After much looking around on the market and test driving and the like we decided to purchase a vehicle through a company that I had previously worked for.

I agreed to purchasing the car on 0% finance and was promptly taken to a private room to go through their credit searching system. No one was as surprised as me to discover that the credit searching system I had worked on 10 years previously, at the finance arm of the company, was still functioning and was about to credit check me!

There was a brief moment when I had to cast my mind back to make sure that I hadn’t left any ‘testing’ back doors in the application that I might trigger if I was to apply but then I remembered that I had not because I had a feeling that one day it might come back to haunt me. Relieved about this I settled down to the long drawn out question and answer process that is credit scoring in the UK. But then something strange happened (room spins) Continue reading “refused by my own credit scoring system!”

rozenshtein method for pivoting relational data

I came across this blog entry while trying to make up for the fact that SQL server 8 does not have the PIVOT statement that I needed. It’s taken from a book (that I don’t have) by Rozenshtein on advanced database queries.
The blog explanation is lengthy and a little confusing but the idea is deceptively simple. It hinges around being able make a column expression that can ‘select’ data.

Continue reading “rozenshtein method for pivoting relational data”