Book Image

Hands-On Design Patterns with Delphi

By : Primož Gabrijelčič
Book Image

Hands-On Design Patterns with Delphi

By: Primož Gabrijelčič

Overview of this book

Design patterns have proven to be the go-to solution for many common programming scenarios. This book focuses on design patterns applied to the Delphi language. The book will provide you with insights into the language and its capabilities of a runtime library. You'll start by exploring a variety of design patterns and understanding them through real-world examples. This will entail a short explanation of the concept of design patterns and the original set of the 'Gang of Four' patterns, which will help you in structuring your designs efficiently. Next, you'll cover the most important 'anti-patterns' (essentially bad software development practices) to aid you in steering clear of problems during programming. You'll then learn about the eight most important patterns for each creational, structural, and behavioral type. After this, you'll be introduced to the concept of 'concurrency' patterns, which are design patterns specifically related to multithreading and parallel computation. These will enable you to develop and improve an interface between items and harmonize shared memories within threads. Toward the concluding chapters, you'll explore design patterns specific to program design and other categories of patterns that do not fall under the 'design' umbrella. By the end of this book, you'll be able to address common design problems encountered while developing applications and feel confident while building scalable projects.
Table of Contents (18 chapters)
Title Page
Copyright and Credits
About Packt


The observer pattern regulates communication between an object (called a subject) and other objects (observers) that want to react to changes in the subject. Instead of checking periodically for changes, observers register their interest with the subject and are notified about the changes with some callback or messaging mechanism.


If you subscribe to a magazine, you don't go to the publisher every day to check if a new edition is ready. Rather, you wait until the publisher sends you each issue.

This Gang of Four pattern is a basic part in distributed event handling systems. For example, a Model-View-Controller architectural pattern is always implemented with some application of the observer pattern.

The Live Binding mechanism that's in Delphi is also based on the observer model. It uses the observer mechanism built into the component library (the TComponent.Observers property).

Any implementation of the observer pattern follows the following steps:

  1. The observer registers its interest...