The Road To Delphi Prism

by John 11/27/2008 6:30:00 AM

I figured it might be quite interesting to take an existing web application created in Delphi 2007, move it into Delphi Prism and note down the kinds of changes I had to make. The application consisted of 2 assemblies with data access logic and a webapplication containing around 20 or so webpages.

I decided to break my attempt into two stages. The first stage would see me move the data access code into Delphi Prism, I would then reference those assemblies inside the webapplication from within Delphi 2007. The second and final stage would be moving the webapplication.

As a side note I was using Blackfish as my database and the CodeGear ASP.Net providers. 

I started stage one by creating a solution inside visual studio and adding empty assemblies. I then copied my delphi code into the folders and added them to the project. I then went into the project properties and turned on "allow create constructor calls" in the compatibility tab. Having done that I hit the build button and began the process of getting the assemblies to compile.

I made extensive use of the Delphi Prism wiki to get me up to speed on language changes.

 

This is a list of changes I made:-

1) I had used classes with static methods. For example

class procedure SomeMethod;static;

Delphi Prism has static classes, so I removed the static keyword from the individual method and set static at the class level.

SomeClass=public static class

2) TObject no longer exists, so I did a search and replace for TObject with object.

3) Delphi automatically makes classes public in assemblies. I went through all the classes and added public before the class

SomeClass=public class

4) The overload keyword isn't required so I removed that.

5) published doesn't exist. So I replaced that with public

6) I had turned on autoboxing {$AUTOBOX ON} in source files. I removed that.

7) I had been using Delphi namespaces quite extensively. For example I had filenames like namespace1.namespace2.namespace3.pas. The unit inside the .pas was the same as the filename.

To other dotnet languages classes inside the file would exist in namespace  namespace1.namespace2.

I decided to leave the filenames as is and shorten the namespace to the above.

8) attributes use := rather than =, so I modified any occurrences of those.

9) I had used for in like this

var
  x:SomeObject;
  objects:System.Collections.Generic.List<SomeObject>;
begin
  for x in objects do
  begin

  end;
end;

Which results in the warnings 

Warning    1    (PW12) Variable "x" may hide existing variable "x"  

Warning    2    (PW5) Local variable unused: "x"   

The scope of x in the loop is limited, so I decided to remove x from the var so that the code became

var
  objects:System.Collections.Generic.List<SomeObject>;
begin
  for x:SomeObject in objects do
  begin

  end;
end;

10) I had declared events as 

property someevent:eventhandler

I changed that to 

    event TagSelected:EventHandler;

11) Setlength doesn't exist

I used this page as a valuable reference and decided to go with this kind of type declaration.

StringArray2 = array[0..] of String;

uValues:= new StringArray2(fieldDescslength);


All in all I would say a very successful transition. I made full use of unit tests that I had and with minimal debugging I was able to get a working web application.

Stage 2 will follow in another post....

Currently rated 3.0 by 2 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Related posts

Comments

3/30/2009 4:33:16 AM

Michael

This is a very good article. I am ready to give it a try myself and your experience will be helpful.

Michael

Michael us

7/15/2009 4:43:14 AM

pingback

Pingback from answerspluto.com

list of urls - 5 « Answers Pluto

answerspluto.com

5/21/2010 8:00:25 AM

pingback

Pingback from 240.codebluehacks.org

Accessories 300te Performance, Used Classified Mercedes Benz 300te

240.codebluehacks.org

Comments are closed

Powered by BlogEngine.NET 1.3.0.0
Theme by Mads Kristensen

About the author

Name of author John Moshakis
I'm a software developer living in Toronto..

E-mail me Send mail

Calendar

<<  July 2017  >>
MoTuWeThFrSaSu
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

Pages

    Recent posts

    Recent comments

    Authors

    Tags

    Don't show

      Disclaimer

      The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

      © Copyright 2017

      Sign in