I'm currently working on a bit of legacy code. Good code, to be sure, with a rather low technical debt due to the care and hard work by previous programmers. But of course, there are things that stick out. An hour or so ago, I started to refactor an old method that was populating various … Continue reading Recycling is for garbage. Don’t recycle code!
Frame inheritance
Using frame inheritance, possibly in combination with the frame factory pattern (although that is out of scope for this post) can considerably help you limit dependencies, reduce the number of forms and separate concerns of your application. What's the difference between forms and frames? Many Delphi programmers use nested forms to structure their applications, and … Continue reading Frame inheritance
The Factory
Quite a few years ago I landed a Delphi assignment to, among other things, develop a media injector application for a Swedish television broadcaster. It would be part of a much larger system, and its responsibility was to move different clips of mp4 files from one place to another according to a time schedule that … Continue reading The Factory
A comment on comments
Which code is more readable? implementation uses // Delphi units SysUtils, Windows, Classes, // Libraries Lib.Utils, Lib.Settings, Lib.JSON, MainFormU, // Main form unit Settings; // Settings unit procedure TForm.OnButton1Click( ASender: TObject ); var Humpty: THumptyDumpty; begin // Set up a humpty dumpty class and execute it, passing it the personal id, name and what looking … Continue reading A comment on comments
Where’s the white space in the code
Writing code is much like writing a book. There is the intrigue, the story, the chapters and paragraphs. It's all there. But there's often one thing lacking in code that no self-respecting author of a book would ever do without; Readability. An author that want people to read his books has to - on top … Continue reading Where’s the white space in the code
Every program should have an Easter egg
When Steve Jobs and his team finished work on the Macintosh, they fetched a piece of paper and had everyone on the team sign it. So hard had they worked on the new computer, and so proud of the finished product were they that Steve wanted a statement to show it. So he made the … Continue reading Every program should have an Easter egg
Don’t put your publics where your privates should go
Somewhen around 1998 or so some guy at Borland decided that developers are a stupid bunch of people and need the absolutely obvious clarified, so he or she decided to add comments to the unit template to explain where the private and the public declarations should go. unit ContentFrameUnit; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, … Continue reading Don’t put your publics where your privates should go
Empty GUIDs
I use GUIDs a lot. In the case of primary keys, always. But I've often asked myself what value to use for an empty GUID. A googling reveals the answer: In the Types unit, there's a GUID_NULL constant. Who'd know that? Well, now you do.
Visual components as a natural part of a Delphi application
For me, as a long time Delphi developer, custom made Visual components have not been a part of my Delphi VCL applications, nor my various frameworks that's evolved over the years. Not that I don't know how to create a visual component using VCL, but it's just to much work, I think, to bother. But … Continue reading Visual components as a natural part of a Delphi application
Moving the execution point while debugging Delphi
Most people I know are already aware, I've been a Delphi programmer for years and years now. But every day I learn something new. In this article, I'd like to talk about execution points in the Delphi debugger. The execution point is illustrated by an arrow in the left-hand gutter area, you know the one … Continue reading Moving the execution point while debugging Delphi