Delphi Programming Projects
eBook - ePub

Delphi Programming Projects

Build a range of exciting projects by exploring cross-platform development and microservices

  1. 248 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Delphi Programming Projects

Build a range of exciting projects by exploring cross-platform development and microservices

About this book

Improve your Delphi programming skills by building robust applications for Android, iOS, and Windows platform

Key Features

  • Build responsive user interfaces (UIs) for desktop and mobile with FireMonkey
  • Implement a microservices architecture using the Rapid Application Development(RAD) server
  • Create clones of popular applications like Instagram and Facebook using Delphi 10.3

Book Description

Delphi is a cross-platform programming language and software development kit that supports rapid application development for Microsoft Windows, Apple Mac OS X, Android, and iOS.

With the help of seven practical projects, this book will guide you through the best practices, Delphi Run-Time Library (RTL) resources, and design patterns. Whether you use the Visual Component Library (VCL) or FireMonkey (FMX) framework, these design patterns will be implemented in the same way in Delphi, using Object Pascal. In the first few chapters, you will explore advanced features that will help you build rich applications using the same code base for both mobile and desktop projects. In addition to this, you'll learn how to implement microservice architecture in Delphi. As you get familiar with the various aspects of Delphi, you will no longer need to maintain source code for similar projects, program business rules on screens, or fill your forms with data access components.

By the end of this book, you will have gained an understanding of the principles of clean code and become proficient in building robust and scalable applications in Delphi.

What you will learn

  • Get to grips with the advanced features of RTL
  • Understand how to deal with the paradigm change between multiplatform projects
  • Build rich interfaces with Google's Material Design features
  • Understand how to implement design patterns in Delphi
  • Turn a mobile device into a remote controller with app tethering technology
  • Build a multi-database system using VCL

Who this book is for

This book is for developers, programmers, and IT professionals who want to learn the best market practices by implementing practical projects. Prior knowledge of the Delphi language is a must.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Design Patterns to Build a Multi-Database System

Design patterns are structures and relationships that we use repeatedly in object-oriented projects. Understanding them can help you to design better (and thereby improve the development of your software) and design systems that are more complex.
The application of design patterns can improve the quality of the systems that are developed, because they are, in practice, tested and approved solutions to common problems within the programming.
With the use of standards, you can reduce coupling, improve the readability of your code, and increase the degree of reuse of the code. Standards also help other developers to understand your code more quickly.
According to the book Design Patterns: Reusable Object-Oriented Software Solutions, by John Vlissides, Ralph Johnson, Richard Helm, and Erich Gamma (the Gang of Four (GoF)), design patterns are divided into 23 types. Due to this large number of standards, it was necessary to classify them according to their purposes.
According to the GoF, design patterns are divided into three categories:
  • Creational
  • Structural
  • Behavioral
Delphi fully implements an object-oriented language with a lot of refinements that simplify development.
The attribute classes of a particular pattern, which are also the most important, are the basic inheritance classes; abstract and virtual methods; and the use of the protected and public scope. They provide tools for creating patterns that can be reused and extended, and allow you to isolate varied database functionality from immutable attributes.
In this chapter, our goal will be to develop a multi-database system using some design patterns. Basically, we will use a few patterns. The secret of learning and using certain patterns is that we do not have to use all, or several, in a system. Moderate usage does well, and of course, the code becomes more readable and maintainable.
You will need an intermediate level of knowledge to understand this chapter.
The following topics will be covered in this chapter:
  • Creating a database
  • Models for databases objects
  • Exploring Delphi interfaces
  • Repositories
  • Presentation and final testing

Technical requirements

To get started, you must have a version of Delphi installed on your computer. For our examples, we'll use Delphi Rio, but you can use your version of Delphi, as long as it's from Seattle 10 or later.
The code files for this chapter are present on GitHub, at https://github.com/PacktPublishing/Delphi-Programming-Projects/tree/master/Chapter04.

Project overview

In this chapter, we will build a system that will connect and use two different database managers, using some design patterns for development.
The estimated build time is five minutes.

Getting started

For the multi-database solution, we will use the SQL Server Express and PostgreSQL databases. Any version is supported. In this chapter, the SQL Server 2008 R2 Express Edition will be used (a higher version can be used without problems), and so will PostgreSQL 9.3 (higher versions are also supported).

Creating a database

Before we start to code in Delphi, it is necessary to have the databases created, and to then connect to those databases in Delphi.
For our project in this chapter, we will work with three tables:
  • users
  • products
  • customers
If you have not installed SQL Server 2008 R2 Express Edition (free) or PostgreSQL 9.3 (also free), you can use the database of your choice, but for the best use of this chapter, we strongly recommend that you follow the instructions contained herein:
  • To download SQL Server: https://www.microsoft.com/en-us/sql-server/sql-server-editions-express
  • To download PostgreSQL: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
The installation and configuration of the SQL Server and PostgreSQL database managers will not be covered in this chapter.

Creating an SQL Server database

To create the database and its tables in SQL Server, we will connect to our server through the database management system:
In the preceding screenshot, I am using SQL Server 2008 R2; however, you can use a higher version. The SQL version is not relevant in this case.
Next, we will create the database (the database file itself). There are two ways: one uses the form panel visually, and the other uses SQL code.
As a more didactic and illustrative example, we will visually create the database with the following steps:
  1. With the server connected, select the Database tab and right-click on New Database...:
  1. Give the database the name PACKT, and confirm:
Once this is done, the PACKT database will be created on your disk drive.

Creating tables in SQL Server

Once you have created the PACKT database, you can create the users, products, and customers tables.
To do this, follow these steps:
  1. With the PACKT database selected in Object Explorer, create a new query.
  2. Write the SQL code for the creation of the following tables:
  • The SQL code for the users table is as follows:
CREATE TABLE users(
id_user int IDENTITY(1,1) NOT ...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. Dedication
  4. About Packt
  5. Foreword
  6. Contributors
  7. Preface
  8. Building an Instagram Clone
  9. Building a Facebook REST API
  10. Cross-Platform Services for Windows, iOS, and Android
  11. Design Patterns to Build a Multi-Database System
  12. Creating GUI Apps with FireMonkey
  13. Implementing Tethering to Create a Remote Control
  14. Building Microservices Using the RAD Server
  15. Other Books You May Enjoy

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Delphi Programming Projects by William Duarte in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming. We have over one million books available in our catalogue for you to explore.