Delphi is great for beginners. However, the step up to C-class languages is a must. I’ve had today to check an odd bug, and I was lucky enough to quickly view the following statement:

    result := iif( obj <> nil, obj.Id, UNKNOWN );

I’ve refactored it to:


if obj = nil then
begin
   result := UNKNOWN;
end
else
begin
   result := obj.id;
end

Being a C++ guy, I felt hatred towards Borland and their followers: how can they ask for a language without a ternary operator? If the code were C++, the bug wouldn’t have appeared:

return NULL == obj ? UNKNOWN: obj.id;

Also

return NULL != obj ? obj.id : UNKNOWN;

would have worked fine.

Advertisements