Best Practices, Migration and Ecosystem

50.1 Coding Standards (Common Conventions)

Types (classes, records, enums) T prefix, PascalCase A prefix (common) Lowercase type-abbreviation prefix osPending (or scoped enums) PascalCase or c/sc prefix Components on forms btnSave, edtName, qryOrders

50.2 Best Practices Checklist

✅ Protect every object you create with try..finally Free (or an owner, or interfaces).

✅ Use const parameters for managed types. Use strict private/strict protected.

✅ Keep business logic out of forms. Use data modules, services, and interfaces.

✅ Use parameterized queries. Never concatenate SQL with user input.

✅ Use FreeAndNil for fields that may be checked later. Use Assigned checks for events.

✅ Enable ReportMemoryLeaksOnShutdown in debug builds. Fix all hints and warnings.

✅ Use generics and generic collections instead of TList of pointers. Use TObjectList with ownership.

✅ Use System.IOUtils (TPath, TFile) for cross-platform file paths.

✅ Never access UI controls from background threads. Use TThread.Queue/Synchronize.

✅ Use resourcestring for user-visible text (localization).

✅ Write DUnitX tests for business logic. Use source control (Git) and code reviews.

❌ Avoid with statements, global variables, and auto-created forms you don't need.

❌ Don't mix object and interface references to the same TInterfacedObject.

❌ Don't swallow exceptions (except end;).

❌ Don't pass string/objects across DLL boundaries without shared memory management.

❌ Don't use Application.ProcessMessages as a substitute for proper threading.

50.3 Migration and Modernization

Upgrading old Delphi (Delphi 7 → modern): Unicode migration: string became UnicodeString in 2009. Review PChar/AnsiString usage, binary file formats, Windows API calls (W versions), and SizeOf vs Length in byte buffers.

Replace BDE with FireDAC (the FireDAC migration tool reFind.exe helps rename components).

Update third-party components. 64-bit migration: pointer/integer casts (NativeInt), SendMessage params, inline assembly.

Modernize gradually: generics, anonymous methods, inline variables, System.IOUtils, FireDAC, REST.

VCL to FMX: a rewrite of the UI layer is typically needed. Keep business units UI-agnostic. Tools like Mida Converter can assist.

Free Pascal / Lazarus: a high level of compatibility for non-visual code ({$mode delphi}). LCL is similar to the VCL. Useful for open-source cross-platform targets.

50.4 The Delphi Ecosystem

Libraries / Tools Spring4D (DI, collections, events, mocks), mORMot 2, DMVCFramework, Horse UI component suites

DevExpress VCL, TMS Software (VCL UI Pack, FNC cross-platform), Raize/Konopka, LMD, Steema TeeChart (charts, bundled edition), FastReport, Virtual TreeView (open source), AlphaControls, DelphiStyles

FireDAC, UniDAC/EntityDAC (Devart), TMS Aurelius, Zeos (open source), IBX (InterBase)

JEDI JCL/JVCL, OmniThreadLibrary, Grijjy Foundation, Indy, ICS, Synapse, sgcWebSockets, Skia4Delphi

GExperts, CnWizards, MMX Code Explorer, TestInsight, Parnassus Bookmarks/Navigator, DDevExtensions

Smart CodeInsight (LLM integration in Delphi 12.2+), Delphi LSP, the RAD Studio VS Code extension (DelphiLSP)