1. Home
  2. Computing & Technology
  3. Delphi Programming

Learning Object Oriented Programming with Delphi
OO Programming Concepts

By , About.com Guide

Programming is difficult and OO programming is even more so! A common approach is to provide learners with a set of preconstructed classes (eg a graphics toolbox) as a starting point for OO programming. This module adopts a variation on this approach by using Delphi, a RAD GUI (Rapid Application Development, Graphical User Interface) generator with an extensive library of GUI components. This library allows learners to construct their own visual objects to use and manipulate in their programs. This standard library of user interface objects and the visual (GUI) code generation environment provides a natural vehicle for demonstrating underlying principles and for concretising OO concepts and a good entry point into the complexities of OO programming. It helps to clarify issues like the anatomy of a class, the combination of existing classes to create a new class, and reuse through inheritance by taking advantage of features such as the Visual Component Library (VCL) and Visual Form Inheritance (VFI)).

The first chapter uses Delphi’s GUI generator to start looking at the internal structure of an object. The second chapter looks at RAD-generated inheritance and at the hierarchy of standard user interface components. The third chapter helps the novice OO programmer to write programmer generated classes and the fourth chapter looks at ways of accessing an object and its data.

Chapter two introduces inheritance for reuse through subclassing by presenting VFI and the VCL library supplied with Delphi. Inheritance also provides the possibility of subtyping and the power of polymorphism and this is introduced in chapters four and five, using Delphi’s standard Sender parameter as a starting point. Chapter six draws together the material from the preceding chapters by stating several anti-patterns that highlight potential pitfalls in using inheritance.

Along with polymorphism, the concept of cooperating objects is crucial to OO. Object cooperation in various forms is a theme running from chapter seven through to the end of the module.

The concepts of polymorphism and cooperation are consolidated by the exploration, from chapter nine onwards, of a variety of OO patterns. The following table shows the patterns we’ll cover in this module along with the OO programming concepts these patterns allow us to explore:

Pattern - Concepts
~Immutable - Encapsulation and visibility (private, protected and public fields)
~Sender Argument - Low coupling; Callbacks
~Adapter - Reuse; Implicit delegation; Enabling substitution with unrelated class
~Facade - Low coupling; Implicit delegation; Packaging for simplification
~Law of Demeter - Low coupling; Implicit delegation
~Player-Role - Class definition, distinguishing between attributes and roles; Delegation; Packaging for future evolution; Changing associations dynamically
~Strategy - Packaging for variability (reducing coupling) ; Polymorphic substitution
~Template method - Packaging for variability (reducing coupling) ; Polymorphic substitution; Implementation at different hierarchical levels
~Association class - Class definition; Link (association) information
~Factory method and Abstract Factory - Object manufacture; Separation of concerns
~Singleton - Object manufacture
~Mono State - Class and object data fields
~Decorator - Polymorphic recursion

While contrasting subclassing and subtyping we also consider several inheritance antipatterns.

The fundamental principles of patterns are presented textually and graphically (through words and UML class diagrams, object diagrams and sequence diagrams) and the implementation through detailed worked examples, allowing the student to consolidate the concepts by considering two different perspectives. Using these diagrams brings familiarity in reading class, object and sequence diagrams. This helps develop representational literacy and indicates some of their strengths and limitations.

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. OOP in Delphi
  6. Free Online OOP Course
  7. Learning Object Oriented Programming with Delphi

©2009 About.com, a part of The New York Times Company.

All rights reserved.