Embarcadero Delphi

Topics related to Embarcadero Delphi:

Getting started with Embarcadero Delphi

Delphi is a general-purpose language based on an Object Pascal dialect with its roots coming from Borland Turbo Pascal. It comes with its own IDE designed to support rapid application development (RAD).

It allows cross-platform native (compiled) application development from a single code base. Currently supported platforms are Windows, OSX, iOS and Android.

It comes with two visual frameworks:

  • VCL: Visual Component Library specifically designed for Windows development wrapping Windows native controls and support for creating custom ones.
  • FMX: FireMonkey cross-platform framework for all supported platforms

Running a thread while keeping GUI responsive

Time intervals measurement

Use of try, except, and finally

Strings

Generics

Retrieving updated TDataSet data in a background thread

This FireDAC example, and the others I'm planning to submit, will avoid the use of native calls to asynchronously open the dataset.

For Loops

  • Delphi's for-loop syntax does not provide anything to change step amount from 1 to any other value.
  • When looping with variable ordinal values, e.g. local variables of type Integer, the upper and lower values will be determined only once. Changes to such variables will have no effect on the loops iteration count.

Interfaces

Interfaces are used to describe the needed information and the expected output of methods and classes, without providing information of the explicit implementation.

Classes can implement interfaces, and interfaces can inherit from each other. If a class is implementing an interface, this means all functions and procedures exposed by the interface exist in the class.

A special aspect of interfaces in delphi is that instances of interfaces have a lifetime management based on reference counting. The lifetime of class instances has to be managed manually.

Considering all these aspects, interfaces can be used to achieve different goals:

  • Provide multiple different implementations for operations (e.g. saving in a file, database or sending as E-Mail, all as Interface "SaveData")
  • Reduce dependencies, improving the decoupling and thus making the code better maintainable and testable
  • Work with instances in multiple units without getting troubled by lifetime management (though even here pitfalls exist, beware!)

Running other programs

Using Animations in Firemonkey

TStringList class

Using RTTI in Delphi

RTTI IN DELPHI - EXPLAINED

The Run-Time Type Information In Delphi - Can It Do Anything For You? article by Brian Long provides a great introduction to the RTTI capabilities of Delphi. Brian explains that the RTTI support in Delphi has been added first and foremost to allow the design-time environment to do its job, but that developers can also take advantage of it to achieve certain code simplifications. This article also provides a great overview of the RTTI classes along with a few examples.

Examples include: Reading and writing arbitrary properties, common properties with no common ancestor, copying properties from one component to another, etc.

Loops

Creating easily removable runtime error checks