One of the great features of Object Pascal is the inclusion of sets in the language.Other languages have added libraries in support of sets, but Pascal remains unique in having always supported them. Sets are often useful in combination with enumerations. Used together, they provide a very readable approach to handling things such as user…
Category: Food for Thought
The Simple Things…
I recently opened up an interesting piece of software from a github repository. I will leave it unnamed, as it serves as the trigger for this article, and demonstrates some poor practices I have often seen in legacy projects. You might think that the assignment of types to variables and parameters would be a simple…
Programming to an Interface
Nick Hodges has made “program to the interface, not the implementation” a mantra for good practice. And I completely agree. My focus continues to be on legacy projects, as most of my work lies in that area. As much as I love Delphi 12 Athens, I spend the majority of my time in Delphi 2007,…
Strategy for Global Variables
Global variables are generally considered to be bad. This is especially the case where state variables are concerned. However, as my focus has been, and continues to be, on legacy projects, global variables are a reality to be managed. Maintaining a project which has many global variables is a challenge. Depending on the names which…
Why Comments
Discussions about commenting code can be surprisingly heated. Some will say that good code should explain itself, and needs no comments. Others will insist on the need for comments without actually approaching any discussion of how to distinguish good from bad comments. Bad comments are easy enough to recognize. Many simply repeat in plain language…
Keep it Small
Small is good. Small is simple. We should strive to keep things small in our development work. Keep routines short and simple. Use as few local variables as possible. Avoid long parameter lists. Keep scope as narrow as possible. If you find yourself challenged by these things, it suggests the need for practice and thought….
YAGNI: Is it Absolute?
YAGNI – You Ain’t Gonna Need It – is a useful principle in software development and rework. But should it be a hard rule? I will argue that it should be a guide, not a rule. But also, that the context is a major factor in determining which view should apply. The first and obvious…
On Forms…
It seems that relatively few Delphi developers routinely make use of the anchors and constraints on forms. Why this should be is a mystery to me, but I am only commenting on observations. When you create a form and place some controls, the anchors for the controls are, by default, set to top and left….
Sober Reflection
In my book I wrote that we may be the enemy. Delphi is a powerful tool, but is not free from defects. Any non-trivial software has defects. All too often we may find cause to complain of the IDE, and some of those complaints are surely justified, but what role have we played in introducing…
Those pesky details…
The little things in code are easily overlooked, and can be the source of problems which are difficult to diagnose. Consider the conversion of a string to a number: 1 d := StrToFloat(NumericString); What could go wrong? Well, many things, actually. In writing this, you no doubt were thinking of the problem at hand, rather…