John Kaster

Behind the Screen

Delphi Cookbook review

leave a comment »

Review of the book Delphi Cookbook by Daniele Teti.

Before proceeding with my review, you may want to read this other review by Simon J Stuart which provides a good overview of what you can find in the book. I also received a review copy from the publisher, and I’m glad I requested one!

Overall impression

The book uses a great pattern, where a topic is introduced, code is shown to demonstrate it, explanations and observations about the technique are discussed, and suggestions for additional usage or other resources are provided. This “explore more” section of the book may actually be its most valuable part, because Daniele provides specific links that point to good resources to use for each of the recipes covered.

The code examples are useful and as concise as is reasonable.

The order of the book is logical and does a good job of building on some of the previous recipes in later parts of the book:

  1. Delphi Basics
  2. Become a Delphi Language Ninja
  3. Going Cross-Platform with FireMonkey
  4. The Thousand Faces of Multithreading
  5. Putting Delphi on the Server
  6. Riding the Mobile Revolution with FireMonkey
  7. Using Specific (mobile) Platform Features

This is a valuable book to keep handy for when you may need to implement any of the techniques it covers. In short, it is exactly what a “cookbook” should be, with quick and reliable recipes to help you create a good solution for a technical issue.

Some specifics

For example, there’s a great, short exploration for taking advantage of generics. Hidden in one of the discussed “higher order” functions for generics (map, reduce/fold, filter) is something that deserves to be called out briefly in the book (although it is not).

class function HigherOrder.Filter(InputArray: TArray;
    FilterFunction: TFunc): TArray;
  I: Integer;
  List: TList;
  List := TList.Create;
    for I := 0 to length(InputArray) - 1 do
      if FilterFunction(InputArray[I]) then
    Result := List.ToArray;


This small sample shows one of the cleaner methods of populating a dynamic array result that can subsequently be lifetime managed by the runtime.  The TList object is efficient for growing one item at a time. A dynamic array is not. Often, the result for the dynamic array is preallocated to some high bound (in the sample above, it would be the length of the input array), then resized before the return to shrink the array back down to the number of elements matching the filter. By using TList<T>, then freeing it, the array size is only manipulated once and the List.ToArray call makes the code clean and sustainable.

Mobile development with Firemonkey

The book has many detailed and useful examples for mobile development with FireMonkey. This is the section of the book where I learned the most, because I haven’t worked on mobile apps with Delphi. There are many useful tidbits covered in this section that are important for mobile development: using mobile databases, implementing server and client-side functionality, camera and phone manipulation, application lifecycle awareness, and more.

Platform-specific features

The platform-specific features chapter goes beyond mobile FireMonkey recipes to making calls from Delphi to iOS and Android SDK calls, and is an excellent way to wrap up the book.

Other recipes I’d like to see

Some things I think would be good to have in the book are:

  • In the UI section:
    • effective use of actions
    • effective use of frames
    • input value validations (form validation)
  • in the section on streaming, it would be handy to explore reliable determination of the encoding used by a file.
  • for threading, effective use of the new XE7 Parallels library
  • for Delphi on the server,
    • how to secure your web application (including using secure CDN resources for jQuery, etc)
    • using dynamic arrays and records for JSON to avoid all the “free” calls for TObjectList<T> (this works very well with SuperObject, for example)

A minor nit

I don’t understand what Daniele means by “bounce” as in: “I see too many business applications that are composed by a bounce of dialog windows.”


Daniele did a great job on this book, and I hope he continues to update it with new recipes in the future.

Written by John Kaster

November 26, 2014 at 8:31 am

Posted in Delphi

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: