[thelist] ASP: More Selective Select

Paul Cowan evolt at funkwit.com
Fri Jul 4 00:33:36 CDT 2003


rudy wrote:
> see, in my world, a column called MaxEmployeeSalary has *gotta* be
numeric,
> because it's a Salary field

In SQL, fine; in weakly-typed languages, it's not necessarily that easy.

Take VBScript. You've got a variabled called MaxEmployeeSalary.
It's of type 'int' (though it's a variant, obviously, because
they all ARE in VBScript).

It maps to a SQL Server smallint, because... well, because your
company is very miserly and is never going to pay anyone more than
32 grand.

(It's a silly example, but hey. Bear with me)

Elsewhere, you interface with some other system, which passes out
EmployeeSalary, which is kept as a regular SQL int, because... this other
system... (ok, my example is beginning to fall apart) supports
very large salaries indeed. This is kept in a variant of type 'long'.

If your code says
    if (MaxSalary < SalaryFigure) then
        MaxSalary = SalaryFigure
    end if
then, hey, it will work. MaxSalary will become a long, as if by magic.

And your code might work. For months. Or years.

But then, some example comes along where SalaryFigure is 45,000, and
it branches down some conditional code it mightn't have been down
before and tries to stuff it in the DB and, bang, you get an error.
And possibly a nasty one to track down.

If your code says
    intMaxSalary = lngSalaryFigure
then the coder will go, 'hey, the types don't match', and do something
about it. Or the person QAing the code will (you DO QA your code,
right?).

In a strongly-typed language, of course, it's fine. Because in
Java, say, your code will not compile -- or at least give warnings --
if you try and do a potentially unsafe implicit downcast, e.g.:
    MaxSalary = SalaryFigure;
you'll have to do
    MaxSalary = (byte) SalaryFigure;
(or whatever data type); and if you code that, well, that implies that
you know what you're doing and you're sure it's OK -- and you've
DOCUMENTED why it's OK. I hope.

Yes, Hungarian notation is bad: but weakly-typed languages are
EVIL -- E-V-I-L evil.

And you can't write 'lesser of two evils' without E-V-I-L.

> y'all work with data dictionaries and/or schema scripts, right?

Hahahaha. Rudy funny.

Paul



More information about the thelist mailing list