290 likes | 543 Views
Delphi. Jon Krueger Matt Merkel Jack Neil. Overview. Paradigm and problem domains Language concepts Sample code The history of Delphi Language Comparison. Paradigm and problem domains. Delphi follows a imperative and OO model The word Imperative come from Latin and means to command.
E N D
Delphi Jon Krueger Matt Merkel Jack Neil
Overview • Paradigm and problem domains • Language concepts • Sample code • The history of Delphi • Language Comparison
Paradigm and problem domains • Delphi follows a imperative and OO model • The word Imperative come from Latin and means to command. • In imperative languages commands update variables. • Builds directly on what happens at the hardware level.
Paradigm and problem domains • Delphi follows a imperative and OO model • You can look at data structures in terms of states. • The program is a means to manipulate the states. • Variables are used in imperative programming to hold intermediate results of computation. • Other major imperative languages include: Fortran, Basic, COBOL, Algol, PL/1, Modula, C, Ada, Perl
Paradigm and problem domains • Delphi follows a imperative and OO model • Object-Oriented languages are imperative, but considered part of a different paradigm. • Delphi is object-oriented • Inheritance (single) • Polymorphism • Encapsulation
Delphi concepts • Classes (single inheritance) • Interfaces (similar to java) • Exception handling • Built-in support for Unicode strings and single-byte ANSI strings • Very fast compiler and optimizer • Compiles to native x86 code.
Delphi concepts • Values and types – static, strong, standard primitives (char, real, integer, boolean), enumerated, composite (arrays, records, sets)
Delphi Features • Delphi and C++ Builder IDE • GUI Builder – drag and drop • Source editor • Debugger • No runtime environment required to execute Delphi object code.
Delphi Structure • Program Control • Keywords • Begin // starts a statement block • End // terminates a statement block • Exit // exit abruptly from a function or procedure • Halt // terminates the program with an optional dialog • Try // starts code that has error trapping • Uses // declares a list of units (modules) to be imported • Var // starts the definition of a section of data variables
Delphi Structure • Some routines provided with DELPHI • Erase // Erase a file • FileSearch // Search for a file in numerous directories • FileSetDate // Set the last modified date and time of a file • Flush // Flushes buffered text file data to the file • Truncate // Truncates a file size • TStringList // A class provided with DELHPI that has methods for loading and writing a list of strings from a text file
Delphi Example • Reading and writing files var myFile : TextFile; begin AssignFile(myFile, ‘Test.txt’); ReWrite(myFile); //Opens file as new – discards existing contents Append(myFile); //Opens file for appending new data to end Reset(myFile); //Opens a file for read and write access
Delphi Example • A class example
Unit Stringy; interface type TString = Class private stText : String; stWordCount : Integer; stFindString : String; stFindPosition : Integer; procedure GetWordCount; procedure SetText(const Value: String); published constructor Create(Text : String); function Replace(from, toStr : String) : Integer; function FindFirst(search : String) : Integer; function FindNext : Integer; property Text : String read stText write SetText; property WordCount : Integer read stWordCount; end;
//continuation of last slide implementation uses SysUtils, StrUtils; constructuror TStringy.Create(Text: String); begin stText := Text; stFindPosition := 1; stFindString := ‘’; GetWordCount; end; procedure TStringy.SetText(const Value: String); stText := Value; stFindPosition := 1; GetWordCount; end; //other methods here
unit Main; uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Stringy; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; procedure TForm1.FormCreate(Sender: TObject); var myText : TStringy; count : integer; position : integer;
//continuation of last slide begin myText := TStringy.Create(‘The cat in the hat’); myText.Text := ‘There was a cat’; end; end.
History of Delphi • Delphi’s predecessors date back to as early as 1968 • In 1968, a man named Niklaus Wirth began work on a programming language called Pascal, which he completed in 1970 with its first working implementation appearing on a CDC6000 Computer
The Evolution of Pascal • In the 1970s, Wirth worked with Jensen on Modula, the next child of Pascal • In the very early 1980s, Turbo Pascal was born, and received good press for its excellent compilation and execution speed
Delphi Is Born • In the 1990s, a project began at Borland with the Greek Mythological code-name “Delphi” • Borland liked the code-name enough to actually use it as the product name • 1995, Borland’s Delphi was introduced as an Object-Oriented version of Turbo Pascal
Delphi’s Market • Delphi’s main asset was its speed, both in compilation and execution (just like Turbo Pascal) • Designed specifically for RAD (Rapid Application Development) • Ideal for anything from Business and Database applications to intensive application development
Comparison of Delphi • Delphi is most closely related to Visual Basic more than any other programming language • Delphi incorporates Object-Orientation but Visual Basic is much more like traditional Basic in the fact that, it is not Object-Oriented
Comparison of Delphi • Memory management weighs in Delphi’s favor because the programmer has more freedom in managing objects, such as removing them when they are no longer needed, instead of waiting on a “garbage collector.” • Delphi is also broader in the sense of what types of applications it can be used for, whereas Visual Basic’s main applications include only business and database applications
Comparison of Delphi • Lower (hardware and time) cost of execution than Visual Basic • Visual Basic tends to be easier to learn for someone who is not agile or experienced with programming • Visual Basic is more commonly used • New programmers are taught Visual Basic
References • A comparison between Delphi and Visual Basic <http://www.latiumsoftware.com/en/articles/00010.php> • Borland History: Why the name "Delphi?" <http://community.borland.com/article/0,1410,20396,00.html> • Delphi Basics: A brief history of Borland’s Delphi <http://www.delphibasics.co.uk/Article.asp?Name=DelphiHistory> • Delphi Basics <http://www.delphibasics.co.uk>