Patterns are useful

This is not a book about the theory behind patterns; rather, this book focuses on the aspects of their implementation. Before I scare you all off with all this talk about design patterns, their history, modern advances, anti-patterns, and so on, I have decided to present a very simple pattern using an example. A few lines of code should explain why a pattern—based approach to problem solving can be a good thing.

In the code archive for this chapter, you'll find a simple console application called DesignPatternExample. Inside, you'll find an implementation of a sparse array, as shown in the following code fragment:

type  TSparseRec = record  IsEmpty: boolean;  Value : integer;end;TSparseArray = TArray<TSparseRec>;

Each array ...

Get Mastering Delphi Programming: A Complete Reference Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.