Author(s) Danny Thorpe
Title Delphi Component Design
Publisher Addison-Wesley Developers Press
ISBN 0-201-43136-6
Source code on CD
Price 36.95 USD
Level intermediate

Back Cover Info

Delphi Component Design tells the inside story of how and why Delphi was built, and how to make use of this information to build better Delphi components and applications. Whether you're a Delphi application writer yearning to expand into component writing, or you're an experienced Delphi component writer in pursuit of the smaller, faster, better Holy Grail, Delphi Component Design will help you sort out what Delphi Visual Component Library (VCL) services can do for you (and how they do it), what your components can do for VCL, what standard behaviors your component classes must implement, and how to take advantage of little-known VCL classes and services to dramatically improve your component's ease-of-use, code reuse, flexibility, and performance.

Delphi Component Design's three major sections mirror the phases of component creation : Analysis and Design, Implementation Details, and Design-Time Tools.

This is the no-stone-unturned authority on building advanced Delphi components, from high-level views of how a component fits into the grand scheme of things down to the subatomic details of how each link between a component and the rest of the system works, from design-time support tools to run-time performance optimizations.

About the author

Danny Thorpe is an R&D engineer on Borland's Delphi development team. He has served as technical editor and advisor for dozens of Delphi programming books and written articles for PC Magazine and Dr. Dobb's Journal.

Table of Contents



Chapter 1: The Delphi Programming Model
Delphi: 10 Years in the Making

  • In the Beginning
  • OOP Debut
  • New Frontiers, New Challenges
  • A Time for Change
    Lessons Learned
    Delphi Solutions
    The Delphi Application Writer : Component Consumer
  • The Application WriterÕs Skill Set
  • Characteristics of Application Writing
  • Application Writing Opportunities
    The Delphi Component Writer : Component Provider
  • The Component WriterÕs Skill Set
  • Characteristics of Component Writing
  • Component Writing Opportunities

    Chapter 2: Designing Components
    Balancing Design Priorities

  • Usability
  • Extensibility
  • Abstraction
  • Cost of Design Factors
    Reading a Class Declaration
  • Published Sections
  • Public Sections
  • Protected Sections
  • Private Sections
  • Virtual Methods
  • Static Methods and Properties
  • Published Event Properties
  • Nonpublished Event Properties
  • Class Methods
    Identifying Tasks and Parts
  • Spiral Development Process (Iterative Convergence)
  • Decomposition (Finding the Atomic Parts)
  • Identification of IS and HAS Relationships
  • Aggregation
  • Choosing the Right Roots
  • Choosing the Right Implementation Tools
    Operating Within the Implementation Bubble
    Setting the Degree of Extensibility
  • Maximum Extensibility = Minimum Functionality
  • What Makes a Class Less Extensible?
  • What Makes a Class More Extensible?
    Providing Design-Time Support


    Chapter 3: Virtual Methods and Polymorphism
    Syntax Review
    Polymorphism in Action
    The Virtual Method Table

  • Structure of the VMT
  • Inside a Virtual Method Call
    The Dynamic Method Table
  • Structure of the DMT
  • Inside a Dynamic Method Call
    Redeclaring Virtual Methods
  • Why Delphi Supports Redeclaring Virtuals
  • The Effect : Still Compiles, Still Runs Correctly
    Abstract Interfaces
  • Importing Objects from DLLs : The Hard Way
  • Importing Objects from DLLs : The Smart Way
  • Exporting Objects from DLLs
  • Abstract Interfaces Linking User and Implementor
  • Abstract Interfaces Crossing Language Boundaries
    Virtuals Defeat Smart Linking
    Virtuals Enhance Smart Linking
  • Variations on a Theme
  • Life in the Real World
  • Reviewing WhatÕs Really in Your Executables
  • Novelty of Inverse Virtual Smart Linking
    Class Reference Types
    Class Reference Mechanics

    Chapter 4: Exceptions
    An Exceptional Communication System

  • The Fire Brigade
  • Automatic Notification
    Exception Syntax
    Exceptions Change Your Assumptions
  • Assumptions Simplify Source Code
  • Simplification Improves Performance
  • Exceptions Allow Separation of Tasks
    Rules of Thumb for Implementing Exception Handlers
    Rules of Thumb for Raising Exceptions

    Chapter 5: Run-Time Type Information
    The TypInfo Unit
    The RTTI Fountainhead

  • RTTI Advantages
  • RTTI Disadvantages
    RTTI-Supported Types
    Non-RTTI Types
    RTTI Data Structures and Pseudostructures
  • TPropInfo
  • TTypeKind and TTypeInfo
  • TTypeData
    RTTI Routines
  • TypeInfo
  • TObject.ClassInfo
  • GetPropInfo
  • GetPropInfos and GetPropList
  • Property Get Routines
  • Property Set Routines
  • GetEnumName and GetEnumValue
  • IsStoredProp
  • GetTypeData
    RTTI Example Project: Persistent User Data
  • The Task
  • The Solution
  • The Implementation
  • The Application

    Chapter 6: Streaming
    Property-Based Streaming

  • Self-Descriptive Data
  • Property Deltas
  • Property Deltas and Visual Form Inheritance
  • Component Ownership and Parentage
  • Sibling Pointers and Other Cross-Links
  • The Tools of Streaming
    Writing to the Stream with TWriter
  • Initiating Output
  • TWriter.WriteDescendent
  • TWriter.WriteComponent
  • TComponent.WriteState
  • TWriter.WriteData
  • Writing Class-Type Properties
  • TPersistent.DefineProperties
  • TFiler.DefineProperty
  • TFiler.DefineBinaryProperty
  • TComponent.GetChildren
  • TWriter Shutdown
    Reading from the Stream with TReader
  • Starting the Read Process
  • TStream.ReadComponent
  • TReader.ReadRootComponent
  • TComponent.ReadState
  • TReader.ReadData
  • Winding Down the Read Process
    Converting Between Binary and Text
    Streaming Opportunities for Component Writers
  • Published Properties
  • Define Properties
  • ReadState and WriteState

    Chapter 7: Messaging
    Win32 Messaging
    The Message Loop

  • Running the Gauntlet of Filters
  • TApplication.Idle : The Pause That Refreshes
  • Local Message Loops = Modal Dialog Windows
  • Application Start-up and Shutdown : Message Limbo
    Receiving Messages
  • ComponentŠWindow Bonding
  • The Three Message-Handling Opportunities
    Sending Messages
  • External Messages
  • Internal Messages
  • Windowless Window Handles : AllocateHWnd
  • Application.HookMainWindow

    Chapter 8: More VCL Subsystems

  • Establishing the Link
  • Receiving Notifications
    Assign and AssignTo
  • Making the Assignment
  • Implementing Assign
  • The AssignTo Turnabout
  • Non-Self Class Tests and Smart Linking
  • Transferring Data via Properties or Direct Field Access
    Clipboard Support
    GetPalette and PaletteChanged
  • Sharing Resources with a Vengeance
  • Decorating Your Components with Fonts, Pens, and Brushes
  • Using Bitmaps
  • Graphics File Format Extensions

    Chapter 9: OLE and COM Interfaces
    OLE : Interprocess Communication
    COM = Abstract Interfaces

  • Fabricating Proxies to Bridge the Gap
  • Loading In-Process Servers
    Delphi OLE Automation Server: Design Strategy
  • IUnknown (UJane?)
  • Implementing IDispatch
  • Mapping Names to Unique Dispatch IDs
  • IDispatch.Invoke
    Building a Factory
    Registering the Factory
    Automating the Application
    Registering the Application
    Testing the Automation Server

    Chapter 10: Optimization Techniques
    Levels of Optimization

  • The Rosetta Code
  • How Fast Is Fast Enough?
  • When Appearance Is Everything
    The Fine Art of Procrastination
  • Deferring Resource Creation
  • Making Hard-Shell/Soft-Shell Decisions
  • Being a Good VCL Citizen
    Memory Allocation Strategies
  • Trading Memory for Speed
  • Allocate Once and for All
  • Overallocate to Prevent the Creeps
  • Precalculate Data
  • Allocate Uniform Block Sizes
  • DonÕt Allocate at All
  • Local Variables and Stack Memory
    Costs of Value Semantics : Managing Strings and Variants
  • Overhead for Automatic Cleanup
  • Hidden Temporaries
  • String Operation
    Plain Old Dirty Trick
  • Typecasting Incompatible Type
  • Accessing a ClassÕs Protected Member


    Chapter 11: DelphiÕs Open Tools Architectur
    The Big Pictur

  • IDE, Compile Thysel
  • The Component of Component Desig
    Lines of Communication: Interface
    General DesignŠTime Issue
  • When Is the csDesigning ComponentState Set
  • Modifying VCL Source Cod

    Chapter 12: Property Editor
    Standard Property Editor

  • TOrdinalPropert
  • TIntegerPropert
  • TCharPropert
  • TEnumPropert
  • TFloatPropert
  • TStringPropert
  • TCaptionPropert
  • TComponentNamePropert
  • TFontNamePropert
  • TMPFilenamePropert
  • TSetPropert
  • TSetElementPropert
  • TMethodPropert
  • TClassPropert
  • TComponentPropert
  • TColorPropert
  • TCursorPropert
  • TFontPropert
  • TModalResultPropert
  • TShortCutPropert
  • TTabOrderPropert
    Registering Property Editor
  • Global-Scope Registratio
  • Component-Scope Registratio
  • Property-Specific Registratio
    Implementing Property Editor
    Property Editor Rules of the Roa

    Chapter 13: Component Editor

  • TCompnentEditor.Creat
  • Pop-up Menu Item
  • TComponentEditor.Edi
    Modifying the Componen
    Registering Component Editor
    Implementing Component Editor

    Chapter 14: Experts and Add-in Tool
    Explanation of Term

  • Expert Versus Add-in Tool
  • Modal Versus Modeless Window
  • Non-VCL Expert DLL
    TIToolServices: Gateway to the ID
  • Action Method
  • Project/UI Informatio
  • Component Library Informatio
  • Virtual File System Registratio
  • Module Interface
  • Menu Interfac
  • Project Notification
  • Utilities for non-Delphi DLL
  • Error Handlin
    Implementing TIExper
    Installing and Initializing an Exper
  • To DLL or Not To DLL
  • Compiling an Expert into CompLib
  • Building an Expert in a DLL
  • Installing an Expert DLL into the IDE
  • Implementing the Rest of the Expert