Wikia

Delphi Programming

Concept

2,918pages on
this wiki
Talk0

The real world is made of entities and every entity has attributes such as color, weight, size, etc. A concept is based on grouping entities that have the same characteristics but differs only in the value of those characteristics. For example all computers have a CPU but each CPU may differ in speed and performance. The speed and performance are omited measurements at the concept level but an instance of that concept has exact values. Introduction to Objectivist Epistemology by Ayn Rand

In comparison with Delphi, speed is a property of the class and the different types of processing are the methods of the class. In general, when an object "does" something then its done by a method, when an object simply holds a value such as speed or color then that value is a property.

When you create your first class you are defining a concept in Delphi. For example you have the concept of an FTP server. You know that you can log into a FTP server and that you can put files on it and retrieve files from it. In Delphi you would implement this concept by creating a class called, for example, TFTPServer (The naming convention in Delphi for classes is that you prefix them with a capital T). Login, PutFile, and GetFile become the methods of your class. An FTP server also has an IP address, this would become a property of your class. Your TFTPServer class would look like this:

  TFTPServer = class
  private
    FIP: string;
  public
    property IP: string read FIP write FIP;
    function Login(const AUserName, APassword: string): Boolean;
    procedure PutFile(const AFileName: string);
    procedure GetFile(const AFileName: string);
  end;

Around Wikia's network

Random Wiki