Mastering Delphi Programming: A Complete Reference Guide

Book description

Use structural, behavioral, and concurrent patterns in Delphi to skillfully develop applications

Key Features

  • Delve into the core patterns and components of Delphi to enhance your application's design
  • Learn how to select the right patterns to improve your program's efficiency and productivity
  • Discover how parallel programming and memory management can optimize your code

Book Description

Delphi is a cross-platform Integrated Development Environment (IDE) that supports rapid application development for most operating systems, including Microsoft Windows, iOS, and now Linux with RAD Studio 10.2. If you know how to use the features of Delphi, you can easily create scalable applications in no time.

This Learning Path begins by explaining how to find performance bottlenecks and apply the correct algorithm to fix them. You'll brush up on tricks, techniques, and best practices to solve common design and architectural challenges. Then, you'll see how to leverage external libraries to write better-performing programs. You'll also learn about the eight most important patterns that'll enable you to develop and improve the interface between items and harmonize shared memories within threads. As you progress, you'll also delve into improving the performance of your code and mastering cross-platform RTL improvements.

By the end of this Learning Path, you'll be able to address common design problems and feel confident while building scalable projects.

This Learning Path includes content from the following Packt products:

  • Delphi High Performance by Primoz Gabrijelcic
  • Hands-On Design Patterns with Delphi by Primoz Gabrijelcic

What you will learn

  • Understand parallel programming and work with the various tools included with Delphi
  • Explore memory managers and their implementation
  • Leverage external libraries to write better-performing programs
  • Keep up to date with the latest additions and design techniques in Delphi
  • Get to grips with various modern multithreading approaches
  • Break a design problem down into its component parts

Who this book is for

This Learning Path is for intermediate-level Delphi programmers who want to build robust applications using Delphi features. Prior knowledge of Delphi is assumed.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering Delphi Programming: A Complete Reference Guide
  3. About Packt
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
      1. Download the example code files
      2. Conventions used
    3. Get in touch
      1. Reviews
  6. About Performance
    1. What is performance?
      1. Different types of speed
    2. Algorithm complexity
      1. Big O and Delphi data structures
      2. Data structures in practice
      3. Mr. Smith's first program
      4. Looking at code through the Big O eyes
    3. Don't guess, measure!
      1. Profiling with TStopwatch
      2. Profilers
        1. AsmProfiler
        2. Sampling Profiler
        3. AQTime
        4. Nexus Quality Suite
    4. Summary
  7. Fixing the Algorithm
    1. Responsive user interfaces
      1. Updating a progress bar
      2. Bulk updates
      3. Virtual display
    2. Caching
      1. Dynamic cache
    3. Speeding up SlowCode
    4. Summary
  8. Fine-Tuning the Code
    1. Delphi compiler settings
      1. Code inlining control
      2. Optimization
      3. Record field alignment
      4. Assertions
      5. Overflow checking
      6. Range checking
    2. Extracting common expressions
    3. The helpful CPU window
    4. Behind the scenes
      1. A plethora of types
      2. Simple types
      3. Strings
      4. Arrays
      5. Records
      6. Classes
      7. Interfaces
    5. Optimizing method calls
      1. Parameter passing
      2. Method inlining
    6. The magic of pointers
    7. Going the assembler way
    8. Returning to SlowCode
    9. Summary
  9. Memory Management
    1. Optimizing strings and array allocations
    2. Memory management functions
    3. Dynamic record allocation
    4. FastMM internals
    5. Memory allocation in a parallel world
    6. Replacing the default memory manager
      1. ScaleMM
      2. TBBMalloc
    7. Fine-tuning SlowCode
    8. Summary
  10. Getting Started with the Parallel World
    1. Processes and threads
    2. When to parallelize the code?
    3. Most common problems
      1. Never access UI from a background thread
      2. Simultaneous reading and writing
      3. Sharing a variable
    4. Synchronization
      1. Critical sections
      2. Other locking mechanisms
      3. A short note on coding style
      4. Shared data with built-in locking
      5. Interlocked operations
      6. Object life cycle
    5. Communication
      1. Windows messages
      2. Synchronize and Queue
      3. Polling
      4. Performance
    6. Third-party libraries
    7. Summary
  11. Working with Parallel Tools
    1. TThread
      1. Advanced TThread
    2. Setting up a communication channel
      1. Sending messages from a thread
      2. Implementing a timer
    3. Summary
  12. Exploring Parallel Practices
    1. Tasks and patterns
    2. Variable capturing
    3. Tasks
      1. Exceptions in tasks
      2. Parallelizing a loop
      3. Thread pooling
    4. Async/Await
    5. Join
      1. Join/Await
    6. Future
    7. Parallel for
    8. Pipelines
      1. Creating the pipeline
      2. Stages
      3. Displaying the result and shutting down
    9. Summary
  13. Using External Libraries
    1. Using object files
      1. Object file formats
      2. Object file linking in practice
    2. Using C++ libraries
      1. Using a proxy DLL in Delphi
    3. Summary
  14. Introduction to Patterns
    1. Patterns in programming
    2. Patterns are useful
      1. Delphi idioms – Creating and destroying an object
    3. Gang of Four started it all
      1. Don't inherit – compose!
    4. Pattern taxonomy
      1. Creational patterns
      2. Structural patterns
      3. Behavioral patterns
      4. Concurrency patterns
    5. Criticism
    6. Anti-patterns
    7. Design principles
      1. SOLID
      2. Don't repeat yourself
      3. KISS and YAGNI
    8. Summary
  15. Singleton, Dependency Injection, Lazy Initialization, and Object Pool
    1. Singleton
      1. NewInstance
      2. Lateral thinking
    2. Dependency injection
      1. From classes to interfaces
      2. Using a factory method
      3. Wrapping up
    3. Lazy initialization
      1. Using Spring
    4. Object pool
      1. Stock quote connection pool
    5. Summary
  16. Factory Method, Abstract Factory, Prototype, and Builder
    1. Factory method
      1. Painter
      2. Modernizing the factory method pattern
    2. Abstract factory
    3. Prototype
      1. Cloning records
      2. Cloning objects
      3. Delphi idioms – Assign and AssignTo
      4. Serialization
    4. Builder
      1. Idioms – Fluent interfaces
    5. Summary
  17. Composite, Flyweight, Marker Interface, and Bridge
    1. Composite
      1. Child management
    2. Flyweight
      1. String interning
      2. A practical example
      3. Delphi idioms – comparers and hashers
    3. Marker interface
      1. Delphi idioms – attributes
      2. Markers and attributes
    4. Bridge
      1. Bridged painting
    5. Summary
  18. Adapter, Proxy, Decorator, and Facade
    1. Selecting an appropriate structural pattern
    2. Adapter
      1. Wrapping a class
      2. Wrapping an interface
      3. Implementing a queue with a list
    3. Proxy
      1. Delphi idioms – replacing components in runtime
      2. Smart pointers
      3. Unit testing with mock objects
    4. Decorator
      1. Decorating streams
      2. Delphi idioms – helpers
    5. Facade
    6. Summary
  19. Nullable Value, Template Method, Command, and State
    1. Null object
    2. Template method
      1. Calculating the average value
      2. Inversion of control
    3. Command
      1. Command-based editor
        1. Creating commands
        2. Commands
        3. Invoker
        4. Client
        5. Macros
        6. Cloning
    4. State
      1. Unquoting a string
    5. Summary
  20. Iterator, Visitor, Observer, and Memento
    1. Iterator
      1. Delphi idioms – iterating with for..in
      2. Implementing custom enumerators
      3. Using an iterator interface
    2. Visitor
    3. Observer
      1. Observing with Spring
    4. Memento
    5. Summary
  21. Locking Patterns
    1. Delphi idioms – parallel programming
    2. Lock
      1. Custom locking mechanism
    3. Lock striping
      1. Single bit locks
      2. Delphi idioms – bitwise operators
    4. Double-checked locking
    5. Optimistic locking
    6. Readers-writer lock
      1. Comparing reader-writer implementations
    7. Summary
  22. Thread pool, Messaging, Future and Pipeline
    1. Thread pool
      1. Idiosyncrasies of Delphi's TThreadPool
    2. Messaging
      1. Windows messages
      2. Queue and Synchronize
      3. Polling
    3. Future
    4. Pipeline
      1. Web spider
        1. Filter stage
        2. Downloader stage
        3. Parser stage
    5. Summary
  23. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Mastering Delphi Programming: A Complete Reference Guide
  • Author(s): Primož Gabrijelčič
  • Release date: November 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781838989118