We will plan and code a complete application to build a family tree. To keep things simple the tree will only show your direct ancestors and their relatives. Techniques and jargon explained include application design, user interface, object orientation, encapsulation, polymorphism and a simple method of data storage.
If you have some previous experience of the Pascal programming language you may like to create your own code as you work through this text.
The novice should download the code. You will be able to learn a lot of the vocabulary and syntax of Pascal by studying the code as it is discussed in each section of this text.
You need to have Lazarus or Delphi installed. I will assume in this article that you are using Lazarus (Delphi: differences noted in brackets like this).
Create a folder for the code of all your projects so as to keep it all together for easy backup. On Linux this will be in your home folder. On Windows I like to keep all my code in a folder in the root of my “C:” drive however a folder in My Documents is just fine.
In this folder create a sub-folder called something like “Family Tree”. The novice can extract the download code to this folder otherwise I assume that you are creating the project from scratch.
Step one: From the Lazarus menu, create a New... | Project | Application (Delphi: VCL Forms Application) and Save the Project as “FamilyTree” in the folder you just created. (The novice will just open the project).
The project creates the main form which is what the user first sees when they run the application. Save this as “MainForm”.
Exploring the folder you find that the files comprise a code Unit “MainForm.pas” to contain your code and also “MainForm.lfm” (Delphi: “MainForm.dfm”) which contains the specification for the a window where you can place buttons and controls from the Tool Palette.
Lazarus prefers to save files with an all lowercase name, which is encouraged on case sensitive Linux systems to avoid duplicate mixed case file names. (In Windows and with Delphi I prefer CamelCase naming of files for readability).
We can rename “Form1” to be “FormMain” using the “Object Inspector” window at the left side of the screen.
Large enterprise class applications need careful design. More than one developer will be working on software projects so their work must be carefully specified and coordinated. There are modeling tools available to help project managers evolve the design and control the application lifetime development and maintenance.
The design of more simple applications can be roughed out on paper or with very simple applications like “Family tree” we will just put a few components and visual controls on the main form to get an idea what it will look like.
Webmaster Leslie Kaye © 2021 All rights reserved.