I had a problem with typecasting the other day and had the workings of typecasting explained to me on Facebook. Consider this code: var MyFrame : TAbstractFrame; begin MyFrame := GetSomeFrame() as TAbstractFrame; MyFrame := TAbstractFame( GetSomeFrame() ); end; GetSomeFrame returns a frame of TFrame. So I typecast that result into TAbstractFrame (for whatever reason). … Continue reading A thing about typecasting
Category: Delphi
How to get SSL working with Indy components
I like using the Indy components when working with all sorts of internet things, but unfortunately documentation is scarce at best. So I spend hours on hours trying to find some hint as how to do things. Just lately I needed to get SSL working with my REST server for a specific service I offer. … Continue reading How to get SSL working with Indy components
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.