Visit site The Programming Works
February 2012
2
votes
Functional programming style in Delphi
The Programming Works
– Functional programming paradigm gradually finds its way even in Delphi – a procedural language without a garbage collector. Consider the next code sample that changes a button’s caption using extended RTTI (requires Delphi 2010 and above): procedure TForm1.Button1Click(Sender: TObject); ...
January 2012
3
votes
On the Delphi documentation issues
The Programming Works
– Delphi XE2 documentation states: ‘Packed’ Now Forces Byte Alignment of Records If you have legacy code that uses the packed record type and you want to link with an external DLL or with C++, you need to remove the word “packed” from your code. The packed keyword now forces ...
1
vote
On the type compatibility in Delphi
The Programming Works
– Delphi compiler evolves much faster than Delphi documentation, and some language features remain unnamed. Consider the following code snippet: type MyPChar1 = PChar; MyPChar2 = type PChar; MyPChar3 = ^Char; procedure Test(Ch: PChar); begin end; procedure TForm1.Button4Click(Sender: ...
December 2011
7
votes
TThread Facts
The Programming Works
– Delphi RTL TThread class has been an object of criticism since its introduction. Some criticism was deserved, some not. TThread implementation was gradually improving with every Delphi version. Here I am neither criticizing nor advocating the TThread class, just listing some facts about TThread ...
1
vote
Yet Another Word about FreeAndNil
The Programming Works
– The FreeAndNil discussion never stops. I decided to add my twopence. How about this: {.$DEFINE FREEANDNIL} {$IFDEF FREEANDNIL} procedure FreeObj(var Obj); inline; begin FreeAndNil(Obj); end; {$ELSE} procedure FreeObj(Obj: TObject); inline; begin Obj.Free; end; {$ENDIF} With FreeObj procedure ...
1
vote
Hierarchical database structures and Firebird PSQL
The Programming Works
– The idea of storing a hierarchical data in a relational database is very simple, but effective work with such a data requires some knowledge of server-side programming using procedural SQL (PSQL). So the hierarchical data structures are a good chance to get acquainted with PSQL. For demonstration ...
20
votes
Why we need interfaces in Delphi.
The Programming Works
– Objects are normally accessed by an object reference. Interface reference is a different method to access an object’s functionality. A simple question – why do we need interface references at all, why can’t we use object references everywhere? There are several reasons to use interface ...
9
votes
Semaphore throttle
The Programming Works
– Suppose we have an algorithm that uses N parallel threads, and we have a system with M CPU cores, N > M. Running the algorithm on the system leads to performance loss because the threads are contend for available CPU cores and cause time-consuming thread context switching. A better approach is to ...
August 2011
4
votes
Dotted unit names in Delphi
The Programming Works
– For some time now (probably since Delphi 2005; at least the feature is present in Delphi 2007) Delphi has support for dotted unit names (like myLib.myUtils.pas). A fully qualified unit name (myLib.myUtils.pas) consists of a scope prefix (myLib) and a scoped or partially qualified unit name ...
June 2011
4
votes
Sleep sort and TThread corner case
The Programming Works
– If you have not heard it yet – an anonymous genius from 4chan invented a sleep sort, brilliant esoteric sorting algorithm. I have written sleep sort implementation based on Delphi TThread class for rosettacode project, and started to experiment with the code. One of the working variants is: ...
May 2011
1
vote
Generic musings 2
The Programming Works
– It was pointed out in the comments to my previous post that my simple generic sorting routine contains additional overhead compared to TArray Rtl code (Generic.Collections & Generic.Defaults units) because RTTI is used inside the loop. Yes, that is true. Let try to improve the code by taking ...
1
vote
Generic musings
The Programming Works
– Delphi (as Pascal descendant) has always had powerful type system. Consider the following sample code implementing simple insertion sort algorithm (I use Delphi 2009): unit InsSort; interface type TItem = Integer; TArray = array of TItem; procedure InsertionSort(var A: TArray); ...
11
votes
Installing Virtual Treeview
The Programming Works
– Delphi component’s package installation procedure has always been a mess. If you don’t rely on self-made “automated” installations that just copy compiled binaries and do some registry patches that could easily destroy your Delphi installation beyond repair you should do ...
April 2011
7
votes
Best 1st April joke. Ever.
The Programming Works
– My regards to lazarus.su (in Russian). It’s 1st April post was: Lazarus developers announced that the IDE source code is closed and sold to Embarcadero. Under the unconfirmed information the last Lazarus version 0.9.30 will become the base for the next Delphi release – FPC Edition. ...
February 2011
2
votes
How to generate HTML Help with Doc-O-Matic Express
The Programming Works
– XMLDoc in-source documentation style is becoming popular among Delphi open-source projects. There is also very good Delphi Documentation Guidelines document which describes what XML tags should be used for in-source XMLDoc-style documenting comments and how to use these tags. Unfortunately currently ...




