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

Learning Object Oriented Programming with Delphi - Chapter 1
Part 1 - Chapter 1

By Zarko Gajic, About.com

Materials written by John Barrow. Modifications by Zarko Gajic

Introducing:

  • Object orientation basics
  • Delphi Unit structure and project structure
  • Delphi’s RAD generation: visual objects and events

Object Orientation (OO) can be seen from three different aspects: objects as independent entities, objects as derived entities, and objects as interacting entities.

Objects as independent entities

An object is a separate, self-contained, encapsulated entity, and the term encapsulation is important in OO. This means that an object has data that it can keep private from the outside world and that it has specific behaviour. It manipulates its data and implements its behaviour through its methods.

Writing the code that defines an object’s methods has many similarities with structured programming, and so uses many structured programming principles such as structured selection (If..then..else, Case) and repetition (While..do and For loops). In this module we assume that students are familiar with these concepts and so concentrate on principles that apply specifically to OO programming.

Objects as derived entities

Reuse is a very important consideration in OO programming. If some required operations or data storage already exist in one class, it is possible for another class to take advantage of these operations and data and so avoid recoding them. OO makes this second aspect, a class’s derivation from other classes, possible through subclassing (using inheritance) and through composition, and can significantly reduce the amount of code one needs to write.

Objects as interacting entities

The third aspect, the interaction between objects, depends on association and subtyping. If objects could not interact, they could not cooperate with each other to perform the various tasks required in a computer program. So the programmer creates associations (links) between objects to provide pathways for objects to send messages to one another. To allow these interactions to lead to different results under different circumstances, the programmer can use subtyping and polymorphism. Subtyping is when objects within the same hierarchy implement their common interface differently and is an important focus later in this module.

There is considerable interleaving between these aspects. Object derivation and object interaction both use inheritance, which is directly supported in the programming language, and forms of object linking (association and composition), which are not directly supported by language constructs.

Representing OO systems: the UML

It is useful to be able to represent a program in a compact, graphical way as an alternative to the actual code. This module uses a subset of the Unified Modelling Language (UML). The UML provides an integrated and standard set of diagrams that are widely used. In this module we concentrate on class, object and sequence diagrams to capture the static and dynamic aspects of the programs and to present the underlying OO principles.

Patterns: applying OO principles

While the basic OO principles are quite simple, their application can become extremely sophisticated. Members of the OO community has adopted the concept of Software Patterns to capture this expertise, combining the experience of many experienced OO programmers. This module takes the student through several important Software Patterns, using them to solve specific problems and to see how best to apply general OO principles.
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 - Chapter 1

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

All rights reserved.