Solved

Best way to convert Delphi 6 code to C#

Posted on 2013-06-28
5
2,027 Views
Last Modified: 2013-07-01
As the title says, I'm looking to convert as much Delphi code to C# as possible.  

I realize there are some tools that will convert whole projects.  I'm thinking this may not be the best way.  Maybe file by file or function by function.  I don't need the designer code converted although having the control names identical to the new C# designer would probably be helpful.

Control names aside, what is considered to be the best solution for people needing such conversions?

Thanks!
0
Comment
Question by:John500
  • 2
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 400 total points
ID: 39285842
The best solution, no matter what language you come from, is to rewrite the application.

Conversions between 2 different .NET languages, say VB.NET to C# can give usable results, because they fundamentally use the same system and the same paradigms. It's only a question of converting the syntax.

However, when you come from a completely different environment, simply adjusting the syntax is not enough. Even trying to convert from VB6 to VB.NET is never a good solution, although the syntax used is the same.

If you look at it closely, Delphi (Pascal) and C# do not do much in themselves. The work is mainly done in classes that they use. The classes in Delphi are not the same as those in C#. And this is where conversions cannot do a good job. A button in Delphi is not the same as a button in C#. They do not have the same properties and methods. Although some can be simply mapped by the converter, many exist in one environment and not in the other one. Same thing for the file I/O classes and the database access classes.

Same thing for all the classes that your application uses.

After the converter has done its job, you are stuck with a lot of code that could not be converted. And the code that could be is not efficient. In order for the application to work as closely as it was doing before, the converters often need to generate a dozen lines of code to reproduce in .NET something that was done in one line in the old environment. Usually, when you code straight in .NET, it's the reverse.

The generated code is thus incomplete, is a mess, a nightmare to debug, and a very bad way to learn how to do things in the framework.

As a .NET trainer, I have witnessed many tries at converting older applications to .NET, from different languages and environments, and almost all of those fell flat, sometimes after days or weeks trying to make the thing works. In most cases, after losing much time, the conversion project is scrapped, and the application either left in its old format or rewritten from scratch.

The very few conversions that do eventually reach production are usually buggy and/or unstable, and are always a pain to maintain.
0
 
LVL 11

Assisted Solution

by:lenordiste
lenordiste earned 100 total points
ID: 39286684
I agree with jamesburger, a rewrite is probably the best way to go!

Also, you while it is tempting to convert this project file by file and function by function, this process will probably yield an "old application written with a new language". Best approach is to document what you need from this application and write it anew. This will help get rid of legacy code or features which may not even be useful anymore! The worst thing is to spend time coding/thinking about how to rewrite a piece of code while the goal is to arrive at the same result, and not the how. The time you'll save going this route will probably leave you with some free time to tweak it further or add new wanted features.
0
 

Author Comment

by:John500
ID: 39286726
Well, thanks to both of you.  I didn't know whether such a tool would at least give me some insight but I can see now it wouldn't be good.

We're talking about a Form Application that has six tabs numerous text boxes, a menustrip, tool strip etc.  The folks that asked me to convert it say it should take about a month.  I don't know.  

Just started working at this place.  I was hoping to utilize some code reuse because they have already converted numerous similar applications.  Nobody gives code away these days except here... or I keep getting the wrong jobs.
0
 
LVL 40
ID: 39286767
You can think of code reuse if the applications where designed as forms in a .exe and most of the functional code in dlls.

You could then rewrite the forms in .NET and simply connect to the old dlls. This works pretty well if the dlls were designed properly.

But if the applications were big .exe that contains everything, a conversion is not something I would consider.
0
 

Author Comment

by:John500
ID: 39289977
Thanks again!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Form design in vb.net 7 21
Create XML 5 35
Base1 Encode/Decode 3 39
Make all values in arrayist to titlecase+vb.net 23 14
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now