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
A comment on ‘Clean Code by Robert C. Martin’
On page 300 of his book Clean Code, Robert C. Martin discusses the use of magic numbers (G25: Replace magic numbers with named constants). Overall I agree with his reasoning, magic numbers like the number of rows of a report or number of columns of a grid or that sort of thing should be replaced … Continue reading A comment on ‘Clean Code by Robert C. Martin’
Best thing about Delphi IDE I’ve learned all year
Thanks Primož Gabrijelčič (for the solution) and Tommi Prami (for the question) of the Delphi Developer Facebook group. I've got 20 years or more as a Delphi developer and I think from the first version I've asked myself the same question as Tommi Prami. Is there a way to sync changes you make in the method definition so they … Continue reading Best thing about Delphi IDE I’ve learned all year
Creating a styled Delphi FMX component the easy way
Recently I had the need to create a styled FMX Delphi component. I had thought about that earlier, as I'm quite skilled at creating VCL components. FMX components are quite another matter though, and the fact that you need to take the style definition into account had just made things cumbersome and a bit awkward, … Continue reading Creating a styled Delphi FMX component the easy way