My “Delphi Cookbook” has been published

Books, Uncategorized 5 Comments »

Almost an year ago I started to write a book about Delphi for Packt Publishing. Today that book has been published.

Delphi Cookbook Cover

Delphi Cookbook Cover

This book is a cookbook! That’s it, in 328 pages you will find useful (I hope) “recipes” for your day-by-day Delphi job.

Topics of the book

  • Create visually stunning applications using FireMonkey
  • Effectively use LiveBindings with the right OOP approach
  • Create server-side programs to serve RESTful web services and provide data to your mobile apps
  • Develop mobile apps for Android and iOS using well-defined GUI design patterns for a great user experience
  • Build efficient mobile apps that read data from a remote server
  • Call the platform-native API on Android and iOS even for an unpublished API
  • Use extended RTTI to better manage the software customization for your customer
  • Leverage the most popular design patterns for a better design without wasting too much time debugging

It is not an introductory book, you will not find any “Introduction to the Object Pascal language”, however the majority of the chapters are not too complex and can be grasped also by the new Delphi programmers.

The book is available for sale on the editor website and on Amazon.

Official book page at PacktPub

Book at Amazon

– Table of Contents –

Chapter 1: Delphi Basics

Changing your application’s look and feel with VCL styles and no code

Changing the style of your VCL application at runtime

Customizing TDBGrid

Using the owner’s draw combos and listboxes

Creating a stack of embedded forms

Manipulating JSON

Manipulating and transforming XML documents

I/O in the twenty-first century – knowing streams

Putting your VCL application in the tray

Creating a Windows service

Associating a file extension with your application on Windows

Chapter 2: Become a Delphi Language Ninja

Fun with anonymous methods – using higher-order functions

Writing enumerable types

RTTI to the rescue – configuring your class at runtime

Duck typing using RTTI

Creating helpers for your classes

Checking strings with regular expressions

Chapter 3: Going Cross Platform with FireMonkey

Giving a new appearance to the standard FireMonkey

controls using styles

Creating a styled TListBox

Impressing your clients with animations

Using master/details with LiveBindings

Showing complex vector shapes using paths

Using FireMonkey in a VCL application

Chapter 4: The Thousand Faces of Multithreading

Synchronizing shared resources with TMonitor

Talking with the main thread using a thread-safe queue

Synchronizing multiple threads using TEvent

Displaying a measure on a 2D graph like an oscilloscope

Chapter 5: Putting Delphi on the Server

Web client JavaScript application with WebBroker on the server

Converting a console service application to a Windows service

Serializing a dataset to JSON and back

Serializing objects to JSON and back using RTTI

Sending a POST HTTP request encoding parameters

Implementing a RESTful interface using WebBroker

Controlling remote applications using UDP

Using App Tethering to create a companion app

Creating DataSnap Apache modules

Chapter 6: Riding the Mobile Revolution with FireMonkey

Taking a photo, applying effects, and sharing it

Using listview to show and search local data

Do not block the main thread!

Using SQLite databases to handle a to-do list

Using a styled TListView to handle a long list of data

Taking a photo and location and sending it to a server continuously

Talking to the backend

Making a phone call from your app!

Tracking the application’s life cycle

Chapter 7: Using Specific Platform Features

Using Android SDK Java classes

Using iOS Objective-C SDK classes

Displaying PDF files in your app

Sending Android intents

Letting your phone talk – using the Android TextToSpeech engine

I hope you enjoy the reading!


ITDevCon 2014, Call4Papers

Android, DMVCFramework, Design Patterns, Embarcadero, Events, ITDevCon, ITDevCon2014, Programming, Projects, RTTI, bit Time Software, iOS Comments Off

ITDevCon 2014

ITDevCon 2014

Dear potential ITDevCon speaker,

As every year, I’m building the agenda for next ITDevCon that will be held next october 23th, 24th in Milan (Italy), in a new location.

This will be the 6th edition ( we’re getting conference experts J )

The call for papers are officially open right now, so if you want to propose some speeches, I’ll be glad to see it.

As usual, for the Call4Paper I need:

  • Title (for every talk)
  • Abstract (for every talk)
  • Difficulty level (for every talk. Difficulty level is a scale from 1 to 3 with the following mean: introduction, intermediate, advanced)
  • Speaker’s photo
  • Speaker’s profile

I’m looking forward to your proposal. The call4papers ends at Aug 31st, 2014 but if you have *VERY* interesting topic to propose, propose it… I’ll try to arrange the schedule and fit it in the agenda.

Send your proposal to call4paper(at)

Proposals will be evaluated and the speakers will be contacted ASAP.

This year topics will be the following:


  • What’s new in the latest Delphi versions

  • FireMonkey platform

  • MacOSX development

  • Android development

  • iOS development

  • Windows development

  • Mobile development (Android+iOS)

  • Develop UIs for different devices (smartphones, tablets, TV, watch etc)

  • BaaS integrations

  • LiveBindings ®

  • Delphi best practices

  • Design Patterns

  • DataSnap

  • DelphiMVCFramework

  • Arduino e/o Raspberry Pi

  • Web Application with Delphi

  • TDD and Unit Tests

  • Agile methodologies

  • ORM and other data access patterns

  • Using NoSQL databases (even to speed up your VCL software)

  • FireDAC

  • UI, UX, optimization for mobile and desktop


  • Real use cases for extended RTTI, Generics e AnonMethods

  • RESTful interfaces design and development

  • Architectures

Target audience

  • Software architects
  • Software developers
  • Project managers
  • IT managers
  • Trainers

The conference web site is (2014 version is still under construction).

Do you want to see a particular topic or have a suggestion for ITDevCon2014? Let me know

Thanks and see you at ITDevCon 2014.

DelphiMVCFramework is now Open Source!

DMVCFramework, Delphi XE4, Delphi XE5, MVC, RTTI 3 Comments »

DelphiMVCFramework Logo

Yes, just after 1 year of development, and a couple of big projects developed with it, the DelphiMVCFramework has been published as OpenSource.

The project is on google code svn

I’ll talk about it at ITDevCon2013 (

In the trunk there are many samples and I’m planning to put many others.

Main DMVCFramework features

  • RESTful (RMM Level 3) compliant
  • Server side generated pages using eLua (Embedded Lua)
  • Messaging extension using STOMP (tested with Apache Apollo and Apache ActiveMQ)
  • Can be used in load balanced environment using memcached (
  • Fancy URL with parameter mappings
  • Integrated RESTClient
  • Works with XE4 and XE5 (tested, but should works also on XE3 and XE2)
  • Experimental support for IOCP
  • Simple, but very very simple, to use…

It contains also a lot of indipendent code that can be used in other kind of projects.

These are the most notable:

  • Mapper (convert JSON <=> Object, ObjectList <=> JSONArray, ObjectLists <=> DataSets)
  • LuaBinding (integrate Lua script into Delphi native code)
  • LuaTextFilter (convert eLua into plain Lua executable script just like JSP)
Currently DMVCFramework use Embarcadero WebBroker framework, but is not tied to it. I’m working on a version that use IOCP (that is 10 times faster than plain WebBroker) and other web libraries for Delphi.
Code is enough stable and is already used in big production system.
There are a couple of bugs that affect WebBroker and so, DMVCFramework.
In our system, I’ve applied some patches to solve these problems. If you need those patches, ask me (I cannot publish the full code because it is Embarcadero licensed code).
The bugs are:
And another bug that affect also DataSnap and TIdHTTPWebBrokerBridge based projects.
Code is tested on XE4 and XE5 but should works also on XE3 and XE2.

ITDevCon 2013 - Some Numbers

ITDevCon2013, Uncategorized, bit Time Software No Comments »

Next week, in Verona (Italy) there will be the 5th edition of the biggest European Delphi Conference.

This year has been extraordinary for the Delphi community. 2 new versions of Delphi and 2 new platforms (with 2 new big markets). There are very many things to talk about at ITDevCon 2013: Android, iOS, HTML5 and Javascript, Web, new frameworks and many other things.

So, I’d like to share with you some numbers about the upcoming conference.

  • 2 days
  • 3 contemporary tracks each day
  • 19 speaker (IT/EN)
    • 7 english only speakers
    • 5 italian only speakers
    • 7 english or italian (on request, based on the class) speakers
  • 31 speeches (60 minutes + 5 minutes for Live Q&A)
  • 5 training tracks (NEW!)
    • D: Delphi
    • M: Mobile (with or without Delphi)
    • W: Web and Delphi
    • G: General Concepts/Methodologies
    • I: Integration with Delphi
  • Speakers and attendees from all Europe
  • Very Special Speaker from Embarcadero…
Moreover we will talk about libraries, frameworks and best practices that really help the Delphi developer in the day-by-day work.
The website is
If you want to attend, buy your ticket here

Sending Android Intents from Delphi (Part 1)

Android, Delphi XE5 4 Comments »

As you probably know, I work for the italian embarcadero representative (, so last week, I’ve been in Milan (Italy) with the Delphi Product Manager Marco Cantù, to show the new Delphi XE5 for Android (and iOS…).

Users (old and new) were enthusiastics. The Delphi-WAY combined with the Android openness and flexibility, is really a good way to develop mobile apps for the business customers.

So, after the initial demos some users were interested in sending Android Intents from their Delphi app.

I’ve builded some demos about Intents, so I showed those demos to them (in the next weeks there will be many Delphi for Android training in Italy, so I’ve build those demo in advance)

In Delphi XE5 you can call java classes from the Google SDK. So I started investigating hot to do this.

There are a lot of possibilities, and I’m still doing research, but this is a simple Intent send demos.

The Intents demo app

The Intents demo app

This is the code under the first button.

procedure THeaderFooterForm.Button1Click(Sender: TObject);
  1. var
  2.   Intent: JIntent;
  3. begin
  5.   // String url = "";
  6.   // Intent i = new Intent(Intent.ACTION_VIEW);
  7.   // i.setData(Uri.parse(url));
  8.   // startActivity(i);
  10.   Intent := TJIntent.Create;
  11.   Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
  12.   Intent.setData(TJnet_Uri.JavaClass.parse
  13.     (StringToJString('')));
  14.   MainActivity.startActivity(Intent);
  15. end;

Simple, isn’t it?

With this piece of code, you cann open your device browser to a web site (my blog in the snippet).

Click on the first button and you will be redirected to this blog.

Open browser with intent

Open browser with intent

Intents are REALLY powerfull

With the next snippet, you can send piece of data (e.g. text) to other apps. You dont have to know the apps in advance, Android will do the match with the Implicit Intent. (It is similat to the TShowShareSheet action).

procedure THeaderFooterForm.Button2Click(Sender: TObject);
  1. var
  2.   Intent: JIntent;
  3. begin
  4.   // Intent intent = new Intent(Intent.ACTION_SEND);
  5.   // intent.setType("text/plain");
  6.   // intent.putExtra(android.content.Intent.EXTRA_TEXT, "Android Rocks!!!");
  7.   // startActivity(intent);
  9.   Intent := TJIntent.Create;
  10.   Intent.setType(StringToJString('text/plain'));
  11.   Intent.setAction(TJIntent.JavaClass.ACTION_SEND);
  12.   Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT,
  13.     StringToJString('Delphi Rocks!!!'));
  14.   MainActivity.startActivity(Intent);
  15. end;

Chose wich apps shoud be launched to handle the intent (and the text)

Chose wich apps shoud be launched to handle the intent (and the text)

Now, if you choose Twitter, you will get this screen.

Intent handle by twitter app

Intent handle by twitter app

I’ve demos about placing a call, sending an SMS, show a PDF file, accessing different kind of storage etc.
In the next part of this mini series I’ll show some other snippets.

There is still many areas to explore…

  • Services
  • BroadcastReceiver
  • Widget
  • Bluetooth
  • I/O
  • …?

I’ll keep you informed…

ITDevCON 2013 - Call 4 Paper

Events, ITDevCon, ITDevCon2013, Uncategorized 3 Comments »



Dear potential ITDevCon speaker,

I’m building the agenda for next ITDevCon that will be held next november 14th, 15th in Verona (Italy), the same location of the past year.

This will be the 5th edition ( we’re getting conference experts J )

The call for papers are officially open right now, so if you want to propose some speeches, I’ll be glad to see it.

As usual, for the Call4Paper I need:

  • Title (for every talk)
  • Abstract (for every talk)
  • Difficulty level (for every talk. Difficulty level is a scale from 1 to 3 with the following mean: introduction, intermediate, advanced)
  • Speaker’s photo
  • Speaker’s profile

I’m looking forward to your proposal. The call4papers ends at Aug 31st, 2013 but if you have *VERY* interesting topic to propose, propose it… I’ll try to arrange the schedule and fit it in the agenda.

Send your proposal to call4paper(at)

Proposals will be evaluated and the speakers will be contacted ASAP.

This year topics will be the following:


  • What’s new in Delphi
  • FireMonkey: component development, hacking styles, best practices, success cases etc.
  • iOS development (iPhone, iPad, iPod Touch)
  • MacOSX development
  • Android clients for Delphi servers
  • Livebindings
  • Windows 8.x
  • Model View View Model (MVVM)
  • Delphi best practices
  • Design Patterns: real world use, success cases
  • DataSnap: intro, success case, tuning, deploing etc
  • “Unusual” Delphi markets
  • Delphi + Arduino
  • Delphi + Embedded Systems
  • Delphi + Raspberry Pi
  • Delphi + WebClient Framework (AngularJS, EmberJS, KnockoutJS etc)
  • Extending Delphi with scripting languages (DWS, Javascript, Lua etc): why? how?
  • TDD and Unit Tests
  • Agile methodologies
  • Dependency Injection
  • ORM
  • FireDAC
  • Software engineering
  • “Hands on” sessions for the most used Delphi frameworks (e.g. Delphi Spring Framework, DORM, TMS Aurelius, OTL etc)
  • Mobile: UI, UX, optimization
  • HTML5/SVG/WebGL and Delphi
  • LLVM
  • RTTI, Generics and AnonMethods: Real world cases, success cases.
  • Web development with Delphi
  • Real OOP Delphi applications developments
  • Delphi fundamentals/advanced
  • Metaprogramming
  • Games
  • Architectures

Target audience

  • Software architects
  • Software developers
  • Project managers
  • IT managers
  • Trainers

The conference web site is (2013 version is still under construction).

Do you want to see a particular topic or have a suggestion for ITDevCon2013? Let me know

Thanks and see you at ITDevCon 2013.

P.S. This year, ITDevCon will be even more amazing! Stay tuned!

“Datasnap Filters Compendium” updated to XE4

Uncategorized 4 Comments »

Very quick info.

Not tremendous useful today as when developed (Delphi 2010 time frame) but, if someone is still using my DSFC, now can find the XE4 version on google code. Currently works all the speed test and the server/client test. Consider this as a very stable beta :-)

Book Review: “ZeroMQ” (PACKT Publishing)

Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Embarcadero, Programming, RAD STUDIO XE 3 Comments »


Some days ago I was contacted by a representative from PACKT Publishing asking me to write a review for their last book about the ZeroMQ library.



In 2009 I was looking for a fast, very fast, messaging system for a complex project and I meet ZeroMQ. At that time there was the 1.x version and I wrote a Delphi wrapper for the C dll that some days later has been included in the official ZeroMQ distribution.

Now, after 4 year since then, I’m using ZeroMQ for a lot of things. I’ve talked about ZeroMQ to the popular ITDevCon (The European Delphi Conference), so I’m very happy to write about ZeroMQ another time.

So, back to the book review…

The book title is simply “ZeroMQ”, but the subtitle explains what you’ll really learn from it: “Use ZeroMQ and learn how to apply different message patterns”.

Yes, this book is really a crash course in ZeroMQ. In about 100 pages, this “small but full of interesting things” book, explains all the most useful message patterns implemented in ZeroMQ. Congrats to Faruk Akgul (the author).

Traditional message queuing systems use a broker. However, ZeroMQ is brokerless. In a brokerless design, applications can directly communicate with each other without any broker in the middle. All the complexity is hidden, and handled, by ZeroMQ. In this situation there isn’t the “single point of failure”. In some cases this architecture cannot be used, but when it can be, you can gain a lot of flexibility, speed with no added complexity.

Let’s give a more  deeper overview for each chapter.

Chapter 1: Getting Started

In this chapter there are some informations about the messaging architectures in general (good for newcomers to the topic) and about ZeroMQ messaging (in particular). Some concepts introduced in this chapter are reused a lot in the rest of the book.

In chapter 1 is introduced the first and the simpler ZeroMQ pattern, the request-replay.

Chapter 2: Introduction to Socket

This chapter starts with a nice introduction to the publish-subscribe pattern and the related filtering (ZeroMQ can filter messages with a very simple “match” pattern). Then, the chapter talks about one of the most interesting patterns when speed is important: the pipeline pattern. While is talking about the pipeline, it explain the ZMQ_PULL and the ZMQ_PUSH socket types. At the end of the chapter, there is an introduction to the Valgrind’s tools suite to detect memory leaks in C/C++ programs. In Delphi can be used FastMM or other similar tools for the same thing.

Chapter 3: Using Socket Topology

In this chapter there is a small introduction to the types of Internet Sockets and TCP. There there is a nice comparison between the “plain” sockets and the ZeroMQ sockets.

At the end, there is an introduction to the CZMQ, a small helper library which lets

C developers to code their ZeroMQ applications easier and shorter. For a Delphi programmer there are a number of ZeroMQ wrapper that makes its use really a snap.

Chapter 4: Advanced Patterns

In this last chapter, are introduced some advanced variation of the previously introduced patterns. Then, there is a nice explanation of some critical situations that could happened in a messaging system. To help the programmer to handle this cases there a number of examples of the ZeroMQ “High Watermark” setting. As very last topic, there is a well known problem, the infamous “slow subscribers in a publish-subscribe pattern”.


The “ZeroMQ” book published by PACKT Publishing is a small but very nice book. Can be very useful to all those people that don’t know about messaging or want add the power of ZeroMQ to their messaging knowledge.

As in every single thing, there are good aspects and bad aspects.

This book is good for an introduction but is not so good for advanced users. There are some other ZeroMQ patterns and features that are not explained at all. However, these patterns are not the most used, or are advanced stuff, so this could not be a big issue.

Considering, the price, the contents and the informative density, is a definitely a good book that can be read, and studied, in few hours and could change your way to do things in everyday programming (messaging are very often not used, or used in a bad way, simply because usually is complex to write and maintain a good messaging system).

One of the more nice features about ZeroMQ is that it can use different transportation protocols. The same library and the same code can be used to do messaging between machines, between processes or between threads in the same process (ipc). As last note, ZeroMQ can handle, without much effort, millions of messages per seconds. If you need speed… consider this.

P.S. I’ll translate and publish on this blog, some of the C examples contained in the book, in Delphi. Stay tuned.

#3 “dorm, the Delphi ORM” bullettin

Uncategorized, dorm No Comments »

A veeery log time after the last dorm bullettin. But, as usual, I was been very busy on some projects (not only dorm) and the time goes by…

However, dorm has been extended, polished and improved over the last few months. Has been used in a couple other projects in my compoany (

So, here’s a small list of improvements and some other tips:

- ObjStatus support (more to come)

- TdormSession non-visual component. Check “\samples\DelphiXE3\TdormSession_Sample01\formSample1.dproj”

- dorm is now in Continuous Integration (not for all supported databases, but I’m improving that)

- I’m integrating a JSON/DataSet/ObjectList mapper into dorm to be used in RESTful DataSnap/WebBroker (or not) http servers. More to come.

- Delphi XE3 Support

- Removes SuperObject as external lib. Now dorm uses an internal patched version.

- More demos added (Most noticeably id under “\samples\DelphiXE3\TODOManager\TODOManager.dproj”)

- Added samples using the new Visual LiveBinding feature in Delphi XE3

About the ObjSupport it’s worth to spend some words about it.

Since the beginning, dorm is completely “perisstence ignorant”: In other words, you can persiste what you want, you dont need to inherit from a specific class or implement a specific interface. This is a very powerful feature but make some internal dorm mechanism very complex. But I really WANT to have this feature, so I’ve added another “mode” to work with dorm: ObjStatus.

If dorm engine finds a property nemed “ObjStatus” of a specific type, it’ll use that property to track the object status (Clean, Dirty, Deleted).

In this way, I gained a *LOT* of speed compared to the prior version regarding persistence of complex objects graph.


procedure DoSomethingOnPersonByID(ID: Integer);
  p: TPerson;
	p := Session.Load(ID);
	p.FirstName := 'Daniele';
	p.Car.Model := 'Civic';
	p.Phones.Add(TPhone.Create('555-555-33-22', 'Home'))
	Session.Persist(p); //generates insert, update, delete for related objects too

As Usual you can find the project code here

DataSnap XE3 concurrency problems and Update1

Delphi XE3, Embarcadero, Uncategorized 4 Comments »

If you know DataSnap, probably you know the famous post by Roberto Schneiders about its stability problems (

Now, after some (right) dust cloud, in the Update 1 Embarcadero fixed some bugs.

I still haven’t the time to do an heavy test but the first “fast-and-dirty” test give some results, and I’d like to share my little tests.

I created a simple “DataSnap REST Application” as a VCL Application.

Start a little test with ApacheBenchmark (you can find it in the Apache HTTPD installation directory).

Run the test… and, exception at the 32° connections, just as before the update. However this is not a “bug”, it is simply a problem related to the default wizard configuration.

So I changed the MaxConnection to 1024. This number is very high (for a simple PC) but I’m interested in the concurrency problems, so I’ve to push the concurrency far enough to che the Update 1 Fixes.



Also, I’ve disabled the session with a little change in the “EchoString” method (as suggested by Marco Cantù in his blog post about DataSnap problems).

Closing the session

Closing the session

Now the test results are good. As I said, my objective is not to check the performance or other problems arised from the Roberto tests. My test is just about the concurrency problems (IMHO the biggest one) and the related crash.

Here the Apache Benchmark tests with 100000 requests with 100 concurrent connections.

D:\wamp\bin\apache\apache2.2.22\bin>ab -v 1 -n 100000 -c100
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
Licensed to The Apache Software Foundation,

Benchmarking (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests

Server Software:
Server Hostname:
Server Port:            8080

Document Path:          /datasnap/rest/TServerMethods1/EchoString/Daniele
Document Length:        22 bytes

Concurrency Level:      100
Time taken for tests:   465.320 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Total transferred:      18966732 bytes
HTML transferred:       2200000 bytes
Requests per second:    214.91 [#/sec] (mean)
Time per request:       465.320 [ms] (mean)
Time per request:       4.653 [ms] (mean, across all concurrent requests)
Transfer rate:          39.81 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1  11.8      0     529
Processing:     2  464 230.4    500    2041
Waiting:        1  457 216.6    499    1922
Total:          2  465 230.8    501    2041

Percentage of the requests served within a certain time (ms)
  50%    501
  66%    565
  75%    609
  80%    637
  90%    699
  95%    769
  98%   1008
  99%   1039
 100%   2041 (longest request)

I certainly will do other tests, however this fast-and-dirty test gave me a good impression.

More to come.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in