A thing about typecasting

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…

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,…

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…

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,…