Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
DelphiModernizationNewsTech Partner

Modernizing Legacy Delphi Code? MVP Oren Aviram Shows You How

delphi-modernization

Modernizing legacy code poses less of challenge than may seem at first sight, as long as the right tool is deployed. In an on-demand webinar from DelphiCon, Embacadero MVP Oren Aviram discusses the challenges of legacy code modernization, and presents Delphi Parser, an intelligent find-and-replace tool that knows Delphi syntax and can even link between objects through code. It’s a Delphi robot that can update an application without harming the legacy code.

But first, let’s look at the reasons behind any given company’s dilemma between modernizing their legacy systems despite their issues, or sticking to “what works” no matter how much times change.

Motives and Drivers

Why do companies refrain from modernizing their systems? According to Oren Aviram, the three main reasons are:

  1. They insist everything “still works”
  2. They are convinced there is “no available alternative”
  3. They want to modernize but do not know how

And what are the main drivers for modernization decisions?

  1. Opportunity to target Windows 10 and 11
  2. Desire to benefit from the capabilities of Delphi 11
  3. Intention to replace the BDE and outdated databases
  4. Need for improved performance, resilience and security

article001

Oren Aviram’s “Delphi Modernization Made Easy” presentation for DelphiCon is a detailed foray into the challenges software developers have faced in modernizing their systems to keep up with the rapid pace of technological advances. He also distills the process of modernization into its constituent parts and aspects, offering the reader a clear understanding of what modernizing Delphi applications entails.

 

Need answers to questions about modernizing your software? CONTACT US!

 

Below is the transcript of the session:

Delphi Modernization Made Easy! [On-Demand Webinar]

Hello and thank you for joining this session of DelphiCon 2021 about Delphi Modernization Made Easy. This session is provided by the Delphi Parser Automatic Modernization Tools and in association with Embarcadero Technologies.

Your host for this session is Oren Aviram. Oren is a legacy Delphi modernization expert and also an Embarcadero Delphi MVP. Oren is the founder and lead developer at Pacifity Technologies Limited, the home of the Delphi Parser automatic modernization tools.

Our session agenda is as follows. We will start with an overview of the legacy IT systems around the world in general and specifically in Delphi as of 2021. We will explain what is a legacy IT system, how they became legacy over the years, and discuss why Borland Delphi is a legacy system.

We will discuss why there is a need to modernize a working Delphi IT system, as well as the benefits of it. We will discuss the legacy Delphi modernization challenges and how to overcome those obstacles.

We will review how you can quickly and easily modernize your Delphi IT system and upgrade your Borland Delphi code to latest Embarcadero Delphi 11 using the Delphi parser automatic modernization tools, and then how to bridge the gap of legacy technology to 2021.

Bridging the Gap of Legacy Technology and Overcoming Obsolete Technology Obstacles

Let’s try to answer the gazillion dollar question: What holds organizations from modernizing their legacy IT system? The immediate answer is because it works. They won’t modernize these IT systems because they work, although with poor performance and security risks, but it works.

Maybe because although they are aware of the situation, they simply think that they don’t have any other options. Maybe they do want to modernize but simply don’t know how.

I am sure it’s not because they don’t want to purchase the new Delphi 11. They will love to work on Windows 10 or nowadays Windows 11. They will love to upgrade the code to work with the new Delphi 11 and make use of all the new technologies.

They will love to get rid of the BDE and move to FireDAC. They will love to get rid of Paradox, old InterBase or Firebird versions and move to modern databases.

They will love to get high performance, high resilience and top security, both for them and their customers. So why won’t they modernize? Something must hold them back. We will try to solve this mystery.

Legacy modernization of IT systems is a serious issue. Well, I suppose that if a business or any organization could have modernized its software in the past 20 years, I believe it would’ve done it already. I also believe that there are many developers that keep on following the technology as it changes and want to be a step ahead of everyone. But businesses as well as organizations don’t work that way.

article007

Well, let’s go back to the late nineties to the times of Windows. In fact, let’s go back to the eighties to the times of DOS. Actually, let’s go back to the sixties to where it all began. In the sixties, IBM developed the Cobol for its mainframes. It was developed for the US Department of Defense for data processing. That is how they called it back then.

Quickly came the banks and the insurance companies that invested in IBM mainframes to computerize their business and control inventory and have control of money. Our money. They were both very happy back then, working with Cobol.

60 years later, they are still there with Cobol. Less happy, but still working. But what happened? Why didn’t they modernize their mainframes to modern operating systems, to DOS in the eighties to Windows in the late nineties? They do have the money for it. They own it. They do have all the knowledge. They have all the experts. They do have all the time, effort, and manpower to do that. I guess it is not because they didn’t want to. It is because they couldn’t and still cannot today. Why? Well, it’s all about the money, the almighty dollar.

In short, these monetary systems were up and running ever since the early sixties. As they became productive and as the years went by super productive, our civilian life became so dependent on them like oxygen. They became unstoppable. They were running day and night through all the major events in US history, getting stronger and stronger with all the technology races, decade after decade, generation after generation, controlling more and more aspects of our lives until they became an integral part of our being.

Let’s face it; money today is no longer a paper bill, but a number in your bank account. Furthermore, all your being is nothing but an ID number in the registry, along with some files that tells the world who you are. Nothing stopped this monetary monster ever since this was brought to life. Not the Cold War, Northern nuclear race, Vietnam War, the man on the moon, Kennedy Watergate or the Civil Rights movement, nor the 9-11 terror attacks nor the Wannacry cyberattacks or nowadays the Coronavirus. Yes, even the Coronavirus pandemic that aimed to shut down the whole world couldn’t stop them. They are unstoppable.

Now, seriously, most of the businesses and organizations who are reluctant to run a modernization process will simply say they’re running Delphi with BDE and Paradox and deployed it to thousands of customers over the years simply cannot make the switch. It’s impossible. They are paralyzed from the idea of having to do that renovation because of the lack of knowledge or expertise.

How can we stop a machine that works? “It is not worth the effort. This will kill my business. I will lose my job. I don’t know what to do. How will I do it? Who will do it? It will take forever. It will cost a fortune. It won’t work right. I cannot make these changes all by myself. I will need to run endless tests to make sure it works. Like before deployment will be a disaster. You won’t take me alive”.

Well, that is why I’m here to help, to show you how it is done right without losing your mind.

Need answers to questions about modernizing your software? CONTACT US!

article002

Taking Control Over Your Delphi Code

Here are the following steps you need to do in order to take control over your Delphi code.

Understand the ecosystem of your code
Analyze your Delphi code
Assess your modernization needs
Take a test drive in the new Delphi 11
Modernize your components
Untie legacy code dependencies

Understand the world we live in. In order to take control over your Delphi code, you need to understand how your IT system works and operates within the whole ecosystem. A legacy IT system is like a solar system. It is a complex environment. It wasn’t built in a day. Some may even say it was there from the beginning of time. Legacy IT systems were built in layers, one on top of the other over the years and yet they are still evolving.

Each layer has its own purpose in life. Even though some of them have already become obsolete by now, they are still there. Legacy IT systems consist of a variety of hardware, network protocols, operating systems, types of user interface models, database servers, reports engines, as well as many other applications and services all surrounding a huge centric monster application hoping it won’t become a red giant and explode one day.

Handling Millions of Lines of Legacy Code

Delphi legacy IT systems rely on their code. Millions of lines of code spread in files and folders as much as thousands of files. Legacy Delphi IT systems code is very centric, unlike modern IT systems that are thin, agile and divided for many small services all speaking to each other in the same protocol. A typical legacy Delphi IT system consists of one main huge application that connects directly to the database server in one legacy network protocol like the BDE and to all other peripheral application and services, each one via its own specific network protocol.

Database oriented legacy Delph IT usually consists of huge amount of hard code sequel queries instead of stored procedures as in modern Delphi code. Modernization of legacy Delphi code requires a profound strategy of analyzing mapping and replacing old code, like the related BDE code to a new code, like FireDAC in all the places in the source code.

article003

Doing it manually, it is a very hard and dirty task. There are many tools that can help you analyze your code and automate the code conversion process. You can start by using a simple editor to find and replace code syntax, but a blind replacement won’t help controlling changes in millions of lines of code spread in so many files. If you wish to automate this process, there are many text replacement tools in the Internet. Some of them are free to use.

You can even try Embarcadero’s refined tool. It’s a free and simple command line tool that finds and replaces text based on a regular expression algorithm.

Handling conversion of syntax within millions of lines of code requires more than that. What you are looking for is an intelligent Find and Replace tool that knows Delphi syntax and understands code logic and can even link between objects through the code like a human developer will do.

A bot that reads and writes Delphi code, a Delphi code robot. This kind of robot will be very helpful. A robot that can quickly read all the source code in all the files through all the projects, not afraid of dealing with millions of lines of code. A robot that can simply load it all to its runtime memory, analyze it all, quickly link between all the code objects and all the libraries, and clearly understand what exactly is needed to be done.

It would be great if it can even link between data related code and database schemes and queries. A robot that will change the code and guarantee that it does not harm the legacy code on the process of rewriting the old code.

With no manmade bugs, with no exceptions, with no learning curve, with no mood changes, with no complaints, with no risks, fast as lightning like a super developer, like an army of developers, like magic.

Luckily for you, there’s a robot like this. It is the Delphi Parser. The Delphi parser is your robot. Using the Delphi Parser provides you total control over your code conversion. The automatic analysis in conversion process reduces manual coding, labor costs and speeds up time to market. The Delphi Parser enables you to run a well-managed migration process with no black holes on a tight budget with a quick and pain-free modernization process. The Delphi Parser is known for providing a highly efficient modernization process with fast results and with an affordable price.

Assess Your Legacy Code

In order to run a successful modernization process, you need to get an assessment of your code. It is like when you want to buy a car or a house, you need to check out some things before making the final decision. If you have a Delphi based IT system using BDE or like and you wish to modernize it and simply don’t know how to start, what to do or expect, we can provide you with a free Assessment for Modernization tool. Quickly download the free edition of the Delphi Parser automatic migration wizard and let it run on your code. You can sit back and enjoy the show while the migration process is in action, migrating your own code in runtime memory. The migration wizard is provided with a built-in migration script, consisting of common commands that fits most legacy code, so as expected, the Delphi robot already knows what to do.

article004

Later, if you wish to instruct the migration wizard to handle specific modernization requests, you can easily tell the robot what to do and it will do what is required with pleasure. As the migration process finishes, you’ll be able to review the changes. The Delphi Parser Migration Wizard provides you answers to important questions like: Exactly how many lines of code do I have through all my projects? How many files in use, what components are being used? Where and how much? How long will it take the migration wizard to convert it all? How many lines of code will be converted? Does it really work?

Analyze your Delphi Code

20 years of software development generated a lot of code and mapping. It is a lot of work. The code resides within millions of lines of code, hundreds of files spread around and shared in many projects within many folders. Understanding what makes your application work is the key to success. If you lead a well-documented code and know exactly what is going on in your code, then it may be easy for you to make this analysis.

Truth must be told, but Legacy Delphi code suffers from lack of documentation. In most cases it has also been developed with no version control. This is due to the fact that 20 years ago developers weren’t aware of documentation procedures or version control. Mostly, they were not aware of the fact that their code will be relevant for the next 20 years.

Using the Delphi Parser’s Code Dependencies Analyzer, you can quickly, easily analyze your Delphi code and get a deep insight into millions of lines of code that was written in the past 20 years and get to places where no human developer has reached ever since.

The Delphi Parser Code Dependencies Analyzer is a very powerful tool. It can scan a complete Delphi project code and link it with all its class libraries like a compiler does, but instead of producing a runtime code, it produces a cross-referenced objects analysis report.

The analyzer can scan all types of source code. Delphi system units and library source code through all versions from Borland Delphi 1 to the latest Embarcadero’s Delphi 11, Third party component library source code, your own proprietary code base units and classes, Delphi five form modules, or DFM files.

Analyzing Delphi Compiled Units

The Delphi analyzer works best with reading text-based Pascal source code. In cases you have an unsupported legacy Delphi compiled library in a form of DCU file without any source code, the Delphi analyzer can even read that and expose its hidden classes and methods.

Yes, you heard me well. The Delphi analyzer can read a Delphi compiled unit, a non-text based DCU file. The Delphi analyzer knows how to decompile a DCU file, reconstruct its objects declaration and expose its and methods, and use it to perform an in-depth analysis for libraries and components with no source code available. This is a very helpful feature that provides you an x-ray vision into compiled code. Using this feature, all the darkest secrets of a legacy Delphi code can be exposed as it clears the way to modernization.

Here are the main features of the Delphi Code Analyzer:

Scans a complete code base in libraries
Analyzes multiple projects
Analyzes mutual shared code
Handle millions of lines of code and runtime memory
Parses code into tokens
Builds object trees
Builds semantic trees
Links between all objects like a compiler does
Maps all objects, local and global
Marks all objects, references
Marks all unit declarations
Marks all objects’ dependencies
Exposes unused code
Exposes black holes
Exposes bugs and errors
Exposes missing declarations
Exposes poor programming
Exposes security weaknesses like possible SQL injections
Builds code analysis reports
Builds complete objects cross references reports
Builds complete code dependencies reports
Enables a code token view and tree view
Enables visual drill down navigator into code
Enables power search for code objects

article005

The Delphi Parser Code Analyzer is the development manager’s new best friend. It helps development teams to get a control over the code and maintain a cleaned and optimized projects code through the development life cycle.

You should use it whenever you wish to release a new version or update and you want to remove unnecessary files in libraries from code before it is deployed. You can download a free addition of the Delphi Parser’s Code Dependencies Analyzer and simply run it on your whole code and get a clear view of your components, units, objects and classes.

The Delphi Parser Code Analyzer provides you a deep insight into your Delphi components and shows you what component is being used, how much and where. Once you have a complete mapping of your Delphi components, you can get the full picture of your code and have a profound knowledge of what are the building blocks that make up your IT system.

Knowing exactly what makes your code work makes it much easier to control it. Analyzing your code is the key to success in every legacy IT system modernization. Once you analyze your code, you will know what legacy components are necessary for you. Those are the ones you will need to modernize.

Now that you know what to do and how, you can start planning your modernization project. In fact, if you already analyzed your code using the Delphi Code Analyzer or ran the Delphi Parser Migration Wizard while I am speaking, you are already running a modernization process.

Now you can quickly migrate all of the required legacy components to new and modern components as well as discarding those you don’t really use. Let me show you how to do it right.

Resolve Unmanaged Code

Using the Delphi Code Analyzer, you can discover and resolve your unmanaged code. The Delphi Parser Analyzer gets inside black holes, finds lost code, and demolishes any prehistoric ghost that hides in the darkest corners of the legacy code. The fear from these ghosts is probably what keeps you and all other developers from touching the legacy code and prevents you from modernizing your code.

Step by step, as you confront all the legacy ghosts like a true Jedi and scare them away, you will gain total control over your code and before you know it, the fear is gone and you become a Delphi warrior.

Remove Unrequired Components and Units From Code

Once you analyze your whole Delphi code, you realize what components are heavily used and where. More important is that you’ll realize what components are not in use or slightly in use, and can be easily removed from the projects.

From my experience through all my years of running huge modernization projects, there is nothing that provides more joy than removing unrequired code from projects. Like a good diet that helps you get rid of excessive weight, it makes you feel good about yourself, so are your applications. They will run faster and perform better.

Okay, now that we have analyzed the code and understand what we need to modernize and how, we can move forward to modernizing its components. Follow these steps to map your Delphi components in use. Delphi components are divided to three major categories, native and standard Delphi VCL components, third party components, and proprietary components.

Need answers to questions about modernizing your software? CONTACT US!

Modernizing Native Borland Delphi Components

Delphi syntax as Object Pascal has not changed much since Delphi 2. It is the same object oriented Pascal language with 32-bit event-driven architecture. The Delphi language has evolved through the years and now supports all new code methodology like generics and automatic reference counting to better control runtime memory management, but it kept its backward compatibility support through all those years, that you can simply take a 20-year-old code that used the native code and components, and simply run it on the latest Delphi 10.4 with minor changes.

You may be surprised to find that most of the native Delphi components, like the standard VCL components, works perfect on the new Embarcadero Delphi 11 with no change at all.

Native Unicode Support

In fact there is a significant change, but you probably won’t see it right away. It is the native Unicode support. Embarcadero’s engineers worked hard through the years to make sure that all the standard VCL components will be native Unicode-based, meaning that all the standard components, Like TEdit, TLabel, TMemo, that works in Borland Delphi as non-Unicode will be automatically Unicode based, with no need to change a single line of code. New Delphi is 100% native Unicode, meaning that all the strings and characters are now native Unicode and you won’t need to make any changes to code to make it Unicode.

As for the code, all string objects are now wide strings as well as TChar is now TWidechar by default. In case you wish to continue work in a non-Unicode environment, you can, but it may require a migration effort. If you find in your code that you need to make specific Unicode or non-Unicode adjustments that spread over your whole code, you can certainly use the Delphi Parser Migration Tool to automate this procedure.

Modernizing Supported Third Party Components

Well, supported third-party components are likely to have a new successor for the latest Delphi and in most cases it will be based on the same structure with backward compatibility support. Some third-party supported components like DevExpress have new additions to all new Delphi 11 editions, but may have significant changes to the structure and will require migration work.

This can be done easily by using the Delphi Parser Automatic Migration Wizard by adding specific migration commands to the migration script to make the required change.

Modernizing Unsupported Third Party Components

It is recommended to replace all the unsupported third party components with a corresponding new supported component that have a similar functionality and code.

If you cannot find a replacement for an important component, which is unlikely, and you have its full source code, check its functionality on the new Delphi 11 and see if it works as expected. If not, you should consider fixing the code to make it work.

In the worst case scenario, when you have an unsupported component with no source code and you cannot find a replacement, you should consider abandoning it and remove its functionality from your project’s code.

Modernizing Proprietary Components

Assuming you have all the source code for these components and they are well supported, you can test them to see how they behave on the new Delphi 11. If they need to be fixed, you may easily migrate them to work in Delphi 11.

In case they are outdated and unsupported, they should be treated as such and you should consider replacing them with a new third party component or native components. If they are not important, you should consider abandoning them.

Test-Drive Your Code

Before you run a full blown modernization process. Invest some time in research and test drive your code in Delphi 11 first. Install the new Windows 11 and play with it for a bit.

Test the compatibility of each component in the new Delphi 11. You may be surprised to see how much of them work in the new Delphi 11. Research the web for a new edition of your components in use. Download the latest trial edition and test them on Delphi 11.

You can also invest some time with the Delphi Fire Monkey components and try building your first mobile application using Delphi 11. Don’t worry, you don’t need to buy the Delphi 11 yet or any of the components. You can simply install their trial edition and play with them.

Need answers to questions about modernizing your software? CONTACT US!

Conclusion

Well, this is the end of this session. In this session, we discuss the legacy Delphi modernization challenges and how to overcome those obstacles and bridge the gap of technology to 2021. If you have any questions about Delphi modernization or want to get more information about it, you are welcome to contact the Delphi Parser.

You can find Delphi Parser at: delphiparser.com

article006


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

6 Comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES