Skip to content

{ Category Archives } Delphi

Generics, Commas, and Semicolons

In Delphi 2009, you declare a generic type with multiple type parameters by separating the type parameters with a semicolon. If the type parameters have a constraint, you separate the constraint using a colon. Like this:

type
TFoo<TypeParam1; TypeParam2: ISomething> = class

This means that TypeParam2 must support ISomething. In C#, you would use where instead [...]

Tagged ,

SQLDA missing or incorrect version, or incorrect number/type of variables

The error in the title comes from InterBase. Actually, the full error is:
[DataDirect][ODBC InterBase driver][InterBase]Dynamic SQL Error, SQL error code = -804, SQLDA missing or incorrect version, or incorrect number/type of variables.
I’ve seen this error before when the wrong InterBase client (gds32.dll) version was loaded by the application, or when the wrong number of variables [...]

Tagged , , , , ,

Testing Is a Legitimate Use Case

How should you unit test private methods? It depends. Some say you shouldn’t do it at all. Others say you should test everything. Who is right?
The problem that I have with a statement like, "Don’t test private methods," is that it is a circular argument. That a method is private implies that you don’t want [...]

Tagged

How to Unit Test a Data Module

Data modules are unit tested in exactly the same way that you would unit test any other piece of code. That is, by refactoring the code to be tested in such a way as to separate it from code not relevant to the test. But since people occasionally seem to find this confusing, perhaps a practical example is in order.

Tagged ,

Functional Programming in Delphi 2009 Video

The video of my CodeRage III presentation on Functional Programming in Delphi 2009 is available for download.

Tagged , ,

OpenCTF - Component Test Framework

In my CodeRage presentation last year, I demonstrated a framework for semi-automatically building unit tests of Delphi components.  I left the project very much in an alpha state, and haven’t had time to return to it, as other things are taking up my time recently.  I still think, however, that the concept of automatically generating [...]

Implementing Memoize in Delphi 2009

My last series on Delphi 2009’s generics was self-consciously investigating a corner case.  This post, however, is going to bring us back to Earth very quickly, so prepare for a steep descent!  I’m going to implement a useful, higher-order function, Memoize, using Delphi 2009’s generics and anonymous methods.
Memoization is a generic solution to the problem [...]

Tagged , , , , ,

Building a Generic Statistics Library, Part 5: Implementation

This post is the last in my series on building a statistics library using Delphi 2009’s new generic types. Having implemented the functions FoldL and Map, and having used FoldL to implement Count and Sum, implementing Average and StandardDeviation are now trivial [...]

Building a Generic Statistics Library, Part 4: Map

It’s been a busy week here in Columbus, what with the highest wind speeds ever recorded in the city and no power in my house — or 1/2 million others — since Sunday.  But don’t feel too bad for me; a lot of people have it worse. Anyway, this will be a fairly short post.
This [...]

Building a Generic Statistics Library, Part 3: Fold

I chose statistical functions as a sample problem because it is so easy to express a statistical function in terms of operations across lists, and operations across lists are what mapping functions do well. In this post, I am going to discuss two list operations, Fold and Map, which will be useful in implementing the Average and StandardDeviation functions. Then I’ll go into some detail about what Fold does and how I use it to compute the sum and count of list elements.

Bad Behavior has blocked 713 access attempts in the last 7 days.

Close