#1 – Working with 20 year old code.

Early on I spent quite a bit of time trying to compile the old source code using the latest tools from Microsoft. Most of the original code was created using Microsoft’s VC++ 6.0, which came out in 1998. These tools were used for most of the product until T&D 8 came out. The Visio flowchart editor in T&D Studio was replaced with an editor written in C#, using Visual Studio 2005. I, along with a couple of contract developers, created a flowchart editor that could be used by both Phoenix Contact’s NanoLine products, and in T&D 8.

I managed to get most of the old code to compile using Visual Studio 2017 (VS2017), but it turned out to be very difficult to debug. There are a lot of DCOM calls between the various components and I was never able to get the interface between the C++ and C# code working.

Rather than continuing to struggle, I decided to re-write the majority of the C++ code in C#. I had always planned on migrating the code to C# in the future, but the time had come to bite the bullet and do it now. As you might expect, this is a large job, but there are some huge advantages.

    • Over the year the original code base grew to support various options which are no longer supported. For example, there is a lot of Visio code still in the code base which is no longer needed. Re-writing TND10 in C# will allow me to leave out all that historical code
    • Working in a product where most of the code is C# eliminate a lot of C++ boilerplate and syntax needed to for the product’s DLLs to work with each other. DCOM only adds an additional layer of complexity. C# DLLs in the same assembly just work with each.
    • The original code was written before a lot of the common architectures that are used today were available. For example, best practice separates the visualization logic (what you seen on the screen) from the business logic (what goes on behind the covers). In T&D 8, there is a lot of visualization code mixed in with the business logic. Re-writing the code give me opportunity to cleanly divide the code up into three major layers: visualization, business logic, and data access. The data access layer (DAL) allows the business logic to work without having to know anything about how a project’s data is stored.
    • There are a few components that will initially remain as C++ application. The T&D Runtime will always remain as a C++ application for several reasons – 1) speed, 2) portability, & 3) low level links to I/O drivers. AppTracker and IOView are both standalone C++ application and should be easy to integrate into the primarily C# environment. They may or may not be writing in C# in the future.
    • Long term, the C# code base will be much easier to maintain and to enhance. I have started a list of some of the features I would like to see in TND10. Feel free to send me your ideas, although most of the enhancements will not make it into the first release. The primary goal of the first release will be stable execution on a 64-bit Windows 10 system with the core drivers. Your survey’s will help me identify the core drivers.

Next update in a couple of weeks.

Tom