The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,952 other followers

Archive for the ‘Delphi’ Category

Reminder to self: write a more extensive blog post on Delphi style guides and code style in general

Posted by jpluimers on 2022/11/30

A while ago, Uwe Raabe reminded me about the Delphi Style Guide which is on-line at the Embarcadero document wiki:

He reminded me to write a bit more about Delphi Style Guides, as there are a few and I used them on past conference sessions.

I thought either the blog post or the conference sessions were already online.

Nope, no 2010 conference sessions at [Wayback/Archive] jpluimers/Conferences: Materials for the conferences that Jeroen Wiert Pluimers spoke on., and no blog post yet.

Hopefully over time I will update that repository, but for now: here is a summary of Delphi Style Guides and a short hint on why to get naming conventions right.

I might extend both in a later blog post, health and time permitting.

Delphi Style Guides

Style guides I found in the past as files named in those session materials:

The above also made me find this interesting post: [Wayback/Archive] Delphi-PRAXiS – Einzelnen Beitrag anzeigen – Delphi Einrücken ::: ::: Wie rückt ihr ein? which mentions these style guides (I modified all links to point to the most recent WayBack machine version that is complete)):

  • Borland empfiehlt folgende Formatierungsregeln:
    http://community.borland.com/article/0,1410,10280,00.html
    Der Punkt 3 “naming conventions” schweigt sich aber über Deine Frage aus 
  • Deutsche Übersetzung der Borland Style Guides
    http://www.dsdt.info/grundlagen/styleguide/
    Unsere Freunde von dsdt.info haben sich die Mühe gemacht und dem Text ins deutsche Übersetzt.
    Damit gibt es nun keine Ausreden mehr sich nicht an die Richtlinien zu halten 
  • Delphi 4 Developer’s Guide Coding Standards Document
    von Econos – Stefan Hoffmeister (1998)
    basiert auf dem Coding standard von Xavier Pacheco and Steve Teixeira
    http://www.econos.de/delphi/cs.html
    Hier gibt es auch eine Liste mit Präfixen zu den einzelnen Komponenten
  • Delphi Object Pascal Coding and Project Organization Standard
    von Michael P. Hollis and Mark S. Lauter
    http://onelauter.com/codestandards/
    Hier wird zwar auch nicht auf die Präfixe eingegangen, aber es wird unter anderem auch eine Verzeichnisstruktur vorgeschlagen.
    Solch ein Dokument mit den einzuhaltenden Regeln sollte in jedem Projekt / Team existieren.
  • Delphi coding Standards
    Maintained by Mustafa GÖKMEN
    http://gokmen.selcuk.edu.tr/document…/delphi/cs.php
    Hier ist auch eine Liste mit Präfixen enthalten
  • Delphi Identifier Naming Conventions
    von Zarko Gajic
    it made it into the WayBack machine
    Dieser Artikel befasst sich nur mit der Benamung von Variablen

The dstgroup version is based on WayBack: onelauter.com/codestandards/CodeStandards.doc.

Mixed emotions conventions

Anyway, this is the piece of code by Uwe Raabe that made me frown as it mixes two Delphi styles at once and uses improper meanings in names:

procedure TSearchForm.StartSearch;
begin
  StatusBar.SimpleText := '';
  dspFiles.Clear;
  Files.Clear;
  BeginSearch;
  SearchFolder(edtRootFolder.Text, edtSearchPattern.Text);
  EndSearch;
end;
 
procedure TSearchForm.SearchFolder(const APath, ASearchPattern: string);
var
  arr: TArray;
  dir: string;
begin
  arr := TDirectory.GetFiles(APath, ASearchPattern);
  AddFiles(arr);
  { release memory as early as possible }
  arr := nil;
  for dir in TDirectory.GetDirectories(APath) do begin
    if not TDirectory.Exists(dir) then Continue;
    SearchFolder(dir, ASearchPattern);
  end;
end;
 
procedure TSearchForm.AddFiles(const AFiles: TArray);
begin
  Files.AddStrings(AFiles);
  dspFiles.Items.Count := Files.Count;
  StatusBar.SimpleText := Format('%d files found', [Files.Count]);
end;

This is the start of technical debt, and resulted in the below cool Twitter thread.

Note that I intentionally used “Digital Signal Processor” as dsp abbreviations are very context sensitive, causing truckloads of problems especially when switching between functionality at front and technical stuff at front in naming conventions.

Functionally, it could have made very much sense to add files into a list to be passed onto a Digital Signal Processor for pre- or post-processing of signals.

Uwe uses this Style Guide (which regrettably does not pay tribute to the original author):

So yes, Uwe posted a cool example on how to apply technology properly, and I retweeted it as this: [Archive] Jeroen Wiert Pluimers on Twitter: “Async Tasks in VCL Projects. Cool example on how to properly to Async in VCL. Important thought: please do not mix naming conventions like Uwe does, as it is substantially adds to your technical debt.… “

It is also a reminder for me to phrase this into the positive form: stick to one naming convention as it makes less technical debt creep in. Like Uwe, I learn new things every day and be reminded it is hart to not follow old habbits.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Where can I find a comprehensive list of Delphi “compiler magic” declarations? – Stack Overflow

Posted by jpluimers on 2022/11/16

A long time ago, I posted one of the answers to [Wayback/Archive] Where can I find a comprehensive list of Delphi “compiler magic” declarations? – Stack Overflow

So for my link archive, these are the main ways of assembling an (always incomplete, as only partially documented) list:

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, EKON, Event, Software Development, Undocumented Delphi | Leave a Comment »

A year ago on Telegram: “Do I need to use GarbageCollectAtoms in Delphi? I used it in delphi 7, but I dont know what is benefit. 😐”

Posted by jpluimers on 2022/10/20

Last week I found out that I had some Windows ATOM issues before, but this beats them easily was still a draft in stead if in the blog queue.

I got reminded to it by someone asking on Telegram about

“Do I need to use GarbageCollectAtoms in Delphi? I used it in delphi 7, but I dont know what is benefit. 😐”.

The short answer is: yes, if your Delphi application does terminate in a way that the Controls unit cannot cleanly unload (and cannot free the Windows atoms) or leaks Windows atoms in a different way. I have been in that situation and that’s why I wrote the above blog post that got published in 2016.

The longer answer is likely no, both the Windows atom and registered Windows message table share a heap and that registered VCL Windows message leaking bug got fixed some 10 years ago in Delphi XE2, see:

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Power User, Software Development, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows NT, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, Windows Vista, Windows XP | Leave a Comment »

The Delphi and Turbo Pascal tools page by Duncan Murdoch has moved domain from www8.pair.com to murdoch-sutherland.com

Posted by jpluimers on 2022/07/13

For a very long time (about 2 decades) Duncan Murdoch had his home page at www8.pair.com/dmurdoch which somewhere in 2021 has moved to

I figured that out thanks to some help from [Wayback/Archive] Pair Networks (@pairnetworks) / Twitter.

So you need to do a replacement of many URL link prefixes

  • from http://www8.pair.com/dmurdoch/
  • to: http://murdoch-sutherland.com/

For instance some old and new pages:

Read the rest of this entry »

Posted in Borland Pascal, Delphi, Development, Pascal, Software Development, Turbo Pascal | Leave a Comment »

Be careful when using the System.Threading unit in versions earlier than Delphi 11 (it ditches Windows XP compatibility, for a reason)

Posted by jpluimers on 2022/06/07

A while ago, I got reminded of a few occurrences of Delphi apps hanging after a little less than 2 months of being active.

It does not happen that often, as usually Patch Tuesday requires a reboot, but sometimes it doesn’t, or ops forgot to patch the affected machine.

The common thing for these hanging apps was that they all used the System.Threading unit (introduced in Delphi XE7). That unit relied on [Wayback] TThread.GetTickcount (added in Delphi XE3 in the System.Classes unit) which uses a 32-bit unsigned [Archive.is] cardinal value as it relied on the Windows API [Wayback] GetTickCount function which in turn has this remark:

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

 
%d bloggers like this: