Categories
.NET article patterns programming windows

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.

Categories
article hardware

iriver clix

iriver clix 4gbSo I ripped 30% of my music as OGG-Vorbis a while ago. I don’t think that necessarily makes me a bad person.

So then you’re faced with the dilemma of how you listen to it. Yeah you want to support non-patented software but it’s really hard to find a player that is still for sale and can be easily purchased that also plays OGG.

Categories
java ruby

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.

Categories
article finance

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)

Categories
database sql

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.

Categories
database sql

secondary school mathematics that was almost useful

For the first time in my career I came across the need to make use of a PRODUCT() SQL aggregate function today. To my dismay SQL Server 8 doesn’t have such a function and so I figured out it can be simulated by use of logarithims and the SUM() function (since (log10(a) + log10(b))^10 = a * b) Therefore my query could read:

SELECT POWER(10, SUM(LOG10(value)))
FROM table

But this query doesn’t work if there are negative numbers in the PRODUCT() list because LOG10(x) where x<0 is undefined. Guess what, there’s a bunch of negative numbers in my list. Arghh …