John Kouraklis
Introducing Delphi ORMObject Relational Mapping Using TMS Aurelius
John Kouraklis
London, UK
ISBN 978-1-4842-5012-9e-ISBN 978-1-4842-5013-6
© John Kouraklis 2019
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.

To my dream Anna

Introduction

Modern software development techniques rely almost exclusively on object-oriented programming (OOP). This approach promotes a specific paradigm that sees fundamental design units (objects) as containers that encapsulate both data and logic (code) and, in many instances, indicates how specific data that stem from business logic should be mapped. This convoluted view contradicts with the other important pillar of information age: the databases.

Storing data and managing databases take developers to a world with different design principles and concepts. Table design, SQL query optimization, and joined table operations are only a few notions that indicate the existence and requirement of different skill sets. On top of this, if one considers the abundance of database engines available in the market and the technical specificity of each one of them, it is not hard to realize the challenges software developers may face given the fact that modern applications rely on the ability to store data in a persistent medium.

Object relational mapping (ORM) frameworks attempt to bring the two worlds of OOP and databases together and provide a toolbox which abstracts the specific requirements of each database. As a result, developers are free to focus on ways to raise business value of their software solutions rather than consuming resources in understanding how to make databases work. ORM promotes reusable coding, automation and standardization of data-related processes, separation of concerns as data access and layers are isolated, and abstraction of database engines; this means that coders who employ ORM libraries are free to switch between databases or even employ different databases without changing a single line of code.

TMS Aurelius is an ORM library developed by TMS Software and targets the Delphi development environment. It is a modern, robust, and efficient approach to the use of databases in an OOP fashion.

This book is dedicated to Aurelius and the Delphi developers who want to make the most out of the framework. It offers a guide in how to embed Aurelius in Delphi projects and how to implement basic and advanced queries, and it moves forward by showing how Aurelius can be used in mobile platforms and in cooperation with third-party providers of JSON-based data.

Who This Book Is For

This book is the perfect companion to both newcomers to Aurelius and to more experienced developers with the framework. It assumes some knowledge of Delphi as it requires familiarity with the IDE and the features of the language. Nevertheless, Aurelius is also available for Lazarus and, therefore, this book appeals to Pascal developers who favor that environment as well.

After reading this book, you will be able to
  • Appreciate the different workflows related to the use of databases as seen from the coder’s side

  • Assess the different uses and features of TMS Aurelius

  • Design applications which use TMS Aurelius

The Development Environment

The code presented in this book is developed using the following environment:
  • Embarcadero Delphi 10 Rio Professional

  • Microsoft Windows 10 Professional

  • FireMonkey framework

  • TMS Aurelius 4.4

  • Android Nougat

  • Steema TeeChart v2018 Standard Evaluation Version

I use the Professional version of Delphi, but I do not use any features exclusive to this version. You can use whichever edition you have access to. I also prefer to develop multi-device applications but this is not a requirement; you can very easily use Aurelius in VCL applications as well. The only exception to this is the projects that show how Aurelius can be used in mobile platforms; these projects require FireMonkey.

Lastly, in Chapter 7 , where Aurelius consumes data from remote servers, I use TMS XData 4.5 Trial version and in Chapter 8 TMS Data Modeler 3.3 is required.

The Book’s Structure

This book has eight chapters. It starts with basic theoretical concepts, then proceeds to the introduction of TMS Aurelius, and as chapters develop it gradually explores different features of the framework.

Chapter 1 : In the Land of ORM

This chapter visits fundamental concepts of ORM frameworks and explores different workflows related to them. It also provides a short discussion of ORM terminology.

Chapter 2 : TMS Aurelius

This chapter introduces TMS Aurelius. It starts by discussing different versions and installation options of the product and shows how the fundamental ideas in ORM that are presented in Chapter 1 are implemented by the framework. This is the first exposure of the reader to code related to Aurelius.

Chapter 3 : Call Center Application

This chapter introduces the CallCentre application. This is an application that presents data from a call center and organizes it in different ways (by department, by agent, etc.). The data set provides some great opportunities to show how Aurelius features work.

Chapter 4 : Basic Operations

In this chapter, we start with basic operations such as how to add, update, and remove entries from the database. We, also, deal with managing nullable and blob fields, and we see how Aurelius can execute large number of SQL statements.

Chapter 5 : Querying the Database

The topic of this chapter is how to build and expand on more sophisticated queries that allow manipulation of data at database level. OOP would indicate that calculations and grouping of data occur in code, whereas database programming relies on the underlying database engine. In this chapter, we see how Aurelius can bring the two together.

Chapter 6 : Enhancements

This chapter looks at more advanced concepts in Aurelius (events, inheritance) and visits the TAureliusDataSet.

Chapter 7 : Aurelius on the Move

As mobile platforms and the Internet become essential part of application development, this chapter takes the task to move Aurelius to mobile platforms. The chapter shows what changes are required for this task and explores different options in this direction.

Chapter 8 : TMS Data Modeler

TMS Data Modeler is a stand-alone application by TMS Software that assists Aurelius users in many ways. This chapter explores the different features of the application and shows how it can contribute to productivity and efficiency.

Code Files

This book comes with Delphi code files. You can access the code by clicking the Download Source Code button located at www.apress.com/9781484250129 . Table 1 provides a summary of the project names used in the book along with some notes.
Table 1.

Project Names Per Chapter

Chapter

FolderProject Name

Notes

 

Misc

This folder contains miscellaneous files that are used in different chapters (image files, data sets, SQL scripts, etc.)

2

Chapter 2BasicFeatures

Demonstrates very basic features in a console application

3

Chapter 3CallCentre (Skeleton)

Provides a project that shows the GUI of the example application. All the subsequent projects are based on this one

 

Chapter 3CallCentre (Without Database Session)

Demonstrates the use of entities, connections, and database manager

 

Chapter 3CallCentre (With Database Session)

Replaces TDatabaseManager with IDatabase Session

4

Chapter 4CallCentre (Without Utilities)

Adds the ability to provide basic operations to entities

 

Chapter 4CallCentre (With Utilities)

Adds basic utilities to handle blobs and exceptions

 

Chapter 4CallCentre (Import)

Demonstrates how to set the object manager in transactional state

5

Chapter 5CallCentre (Listings)

Shows the call lists for agents and departments

 

Chapter 5CallCentre (Queries)

Adds key calculations based on queries

 

Chapter 5CallCentre (Views)

Demonstrates the use of views

6

Chapter 6CallCentre (Inheritance)

Demonstrates different inheritance strategies in Aurelius

 

Chapter 6CallCentre (Events)

Demonstrates the use of events

 

Chapter 6CallCentre (TAureliusDataSet)

Demonstrates different ways to populate TAureliusDataSet

7

Chapter 7CallCentre (Local)

Adapted project to run on Android

 

Chapter 7User

A simple project to fetch JSON content from third-party providers

 

Chapter 7Client

Shows how to use Aurelius to consume data based on REST API from third-parties

 

Chapter 7XData

Demonstrates the use of Aurelius and XData server

8

Chapter 8CallCentre.dgp

Data Modeler project

Table of Contents

Index 249

About the Author and About the Technical Reviewers

About the Author

John Kouraklis

started exploring computers when he was 16 and since then has followed all the way from Turbo Pascal to the latest Delphi versions as a hobby initially and as a profession for most of his adult life. He has developed a wide range of applications, from financial software to reverse engineering tools, including an application for professional gamblers. He is also the author of MVVM in Delphi (Apress, 2016).

 

About the Technical Reviewers

Wagner Landgraf
../images/481234_1_En_BookFrontmatter_Figb_HTML.jpg

holds a Bachelor of Science in Electronic Engineering and a Master of Science in Industrial Computing.

He has 24 years of experience with Delphi development and is the Manager of TMS Business product line at TMS Software, where he serves as Architect and core developer of products such as TMS Aurelius and TMS XData.

 
Nick Hodges
../images/481234_1_En_BookFrontmatter_Figc_HTML.jpg

is a Software Development Manager at Gateway Ticketing Systems, a firm that provides ticketing and access control systems to the largest amusement parks, zoos, and museums around the world. Nick is a software developer at heart. He’s been a Pascal/Delphi developer for over 20 years and still thinks that Delphi is the best development tool out there. He loves to read programming books, attend conferences, and watch cool videos about new programming techniques. He generally tries to be an industry thought leader.

 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.152.198