Delphi for a VB.NET developer [Edit]

Hi EDN,

I have been a VB.NET developer for about three years and have become very comfortable with it. But now I need to develop a small program that will run faster, natively, and without the need for .NET framework being installed. I chose Delphi because I am used to object oriented program and I have learned Dev Pascal a few years back in college. As I am refreshing my memory about the Object Pascal program structure I want to try and compare this to what I know about vb.net. Here are a few of my questions:

1. In Delphi you MUST create an interface before you can create a class. You cannot just create a class that inherits from nothing like in VB.NET, is this correct?

2. When you create a new class with the base class as an interface, you must re-define all of the properties and procedures that are in the interface?

3. Is it possible to define a property or function in a class that is not part of it's interface?

4. Is it possible to derive a class from let's say the TFormClass or would I need to find it's interface to do that?

I am sorry if these questions seem obvious or if I am looking in the wrong direction but I am just a beginner at this...

Perhaps there is some kind of reading meteral that you would reccomend for a VB.NET developer transitioning to Delphi? I already have the Delphi in a Nutshell - Oreilly.

Thanks.
0
Eric
5/26/2010 1:08:14 PM
embarcadero.delphi.non-tech 5933 articles. 1 followers. Follow

14 Replies
801 Views

Similar Articles

[PageSpeed] 18
Get it on Google Play
Get it on Apple App Store

Le 26/05/10 14:08, Eric Painley a écrit :

> 1. In Delphi you MUST create an interface before you can create a
> class. You cannot just create a class that inherits from nothing like
> in VB.NET, is this correct?

No, this is not true. All classes automatically derive from TObject if 
no other class is specified.

Be very careful of interfaces in Delphi, they use a reference-counted 
memory model and should not be mixed with object references (which are 
deterministically released) to the same instance, at least not without 
knowing what you are doing.

> 2. When you create a new class with the base class as an interface,
> you must re-define all of the properties and procedures that are in
> the interface?

Classes do not inherit from interfaces, they implement interfaces. Any 
class that implements an interface must derive, at least, from 
TInterfacedObject.

But, yes, all properties and method declared in the interface must be 
implemented in the class.

> 3. Is it possible to define a property or function in a class that is
> not part of it's interface?

Of course. Classes do not have to have anything to do with interfaces at 
all.

> 4. Is it possible to derive a class from let's say the TFormClass or
> would I need to find it's interface to do that?

As I have said, you don't need anything to do with interfaces to use 
classes in Delphi.

I think you are confusing the fact that all Delphi code units have an 
interface implementation sections. These have nothing to do with 
classes, they are just part of the unit structure.

Classes are declared in the interface section of a unit but their 
methods are written in the implementation section.

Joanna

-- 
Joanna Carter [TeamB|http://www.teamb.com]
Consultant Software Engineer
0
Joanna
5/26/2010 1:29:55 PM
Joanna,

> Any class that implements an interface must derive, at least, from
> TInterfacedObject.

This is not correct. You can derive a class from TObject or whatever you 
want and add an interface to it.
The point is that all interfaces are derived from IInterface so that 
every class or its ancestors must implement all methods of 
IInterface(QueryInterface, _AddRef and _Release).

The TInterfacedObject destroys itself when the RefCount is decremented 
to zero. With not deriving from TInterfacedObject you can change this 
behavior.

-- 
Roman
0
Roman
5/26/2010 1:53:23 PM
> {quote:title=Roman Kassebaum wrote:}{quote}
> 
> This is not correct. You can derive a class from TObject or whatever you 
> want and add an interface to it.
> The point is that all interfaces are derived from IInterface so that 
> every class or its ancestors must implement all methods of 
> IInterface(QueryInterface, _AddRef and _Release).

You are, of course, right. but I was trying to take the simple approach so as not to further confuse the OP, who seems to be quite confused already :-)

> The TInterfacedObject destroys itself when the RefCount is decremented 
> to zero. With not deriving from TInterfacedObject you can change this 
> behavior.

To answer the OP, at this stage in their learning, this is too much detail.

Joanna

--
Joanna Carter [TeamB] http://www.teamb.com
Consultant Software Engineer
0
Joanna
5/26/2010 2:27:43 PM
Eric,

Forget about Interfaces. (for now)
Creating Objects in Delphi is very simple and quite similair as you know it in VB.

http://www.webtechcorp.co.uk/web-developer-training-delphi-article-oop.htm

Only watch out ! 
It can be that after a while you don't want to go back to VB anymore...
0
Robert
5/26/2010 2:31:29 PM
Joanna Carter wrote:

> Be very careful of interfaces in Delphi, they use a reference-counted 
> memory model and should not be mixed with object references (which
> are deterministically released) to the same instance, at least not
> without knowing what you are doing.

	I'm pretty sure he's talking about the interface section of the unit,
though he does seem to confuse it with interfaces.

	The interface section of a unit is a forward declaration of its public
members. It's distinct from the implementation section, where you write
your code. It's different than an interface, which, confusingly, uses
the same reserved word.

	This is the interface section of a unit:

interface

type 
  TFoo = class(TObject) //...

	This is an interface:

interface

type 
  IFoo = interface(IFoo)

	These two uses of "interface" are *completely* different.

-- 
Craig Stuntz · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz/
0
Craig
5/26/2010 2:39:07 PM
On Wed, 26 May 2010 06:08:14 -0700, Eric Painley <> wrote:

>Hi EDN,
>
>I have been a VB.NET developer for about three years and have become very comfortable with it. But now I need to develop a small program that will run faster, natively, and without the need for .NET framework being installed. I chose Delphi because I am used to object oriented program and I have learned Dev Pascal a few years back in college. As I am refreshing my memory about the Object Pascal program structure I want to try and compare this to what I know about vb.net. Here are a few of my questions:
>
>1. In Delphi you MUST create an interface before you can create a class. You cannot just create a class that inherits from nothing like in VB.NET, is this correct?

No.  You can create classes with no parents.

>2. When you create a new class with the base class as an interface, you must re-define all of the properties and procedures that are in the interface?
>
>3. Is it possible to define a property or function in a class that is not part of it's interface?
>
>4. Is it possible to derive a class from let's say the TFormClass or would I need to find it's interface to do that?
>
>I am sorry if these questions seem obvious or if I am looking in the wrong direction but I am just a beginner at this...
>
>Perhaps there is some kind of reading meteral that you would reccomend for a VB.NET developer transitioning to Delphi? I already have the Delphi in a Nutshell - Oreilly.

You seem to be totally focused on interfaces.

I've been working with Delphi for ages.  The only use I've ever seen
for interfaces is working with other code.  Delphi permits classes to
have classes as parents, this works fine.
0
Loren
5/26/2010 4:31:42 PM
On Wed, 26 May 2010 06:29:55 -0700, Joanna Carter
<joanna@no.spam.for.me> wrote:

>I think you are confusing the fact that all Delphi code units have an 
>interface implementation sections. These have nothing to do with 
>classes, they are just part of the unit structure.
>
>Classes are declared in the interface section of a unit but their 
>methods are written in the implementation section.

Good point.

"Interface" in this context is *NOT* even remotely like the interfaces
you know from other langauges!

Think of the "interface" section header as meaning "public" and the
"implementation" section header as meaning "private" or "internal".
0
Loren
5/26/2010 4:31:43 PM
Eric, I think you've probably got the message about 'interfaces' and 'the
interface section' by now.  As a beginner myself, I know how confusing this
can be!

But my advice is: forget about interfaces for now.  You don't need them if
you are just making something small and relatively simple.  And remember:
'the interface section' of a unit is something completely different.  ;-)

SteveT
0
Steve
5/26/2010 5:10:14 PM
Eric Painley wrote:

<snip original message>

http://www.delphibasics.co.uk/Article.asp?Name=Interface

As someone who is gradually working his way to an intermediate skill
level in Delphi, I found this page quite informative regarding
interfaces.

However, as others have mentioned, they are likely not necessary in
your case. It seems to me that interfaces become more important in
libraries when different developers and applications make use of such
code.

Disclaimer: I could be wrong about the above statement.
0
James
5/26/2010 7:31:37 PM
Loren Pechtel explained on 5/26/2010 :
> On Wed, 26 May 2010 06:08:14 -0700, Eric Painley <> wrote:
>> 1. In Delphi you MUST create an interface before you can create a class. You 
>> cannot just create a class that inherits from nothing like in VB.NET, is 
>> this correct?
>
> No.  You can create classes with no parents.
>
First, you mean ancestors.  Parent refers so something else entirely.

Second, this isn't true in either Delphi or .NET.
You can create an object without *specifying* an
ancestor to descend from, and in both languages
it will default to using Object as the ancestor.

HTH,
Brad.

-- 
To people who think about their lives, almost everything
that happens, or that they read, provides a way of learning.
To those who don't examine their lives, all the experience
of the ages is worthless.
0
Brad
5/27/2010 4:32:35 PM
Le 27/05/10 17:32, Brad White a écrit :

> Second, this isn't true in either Delphi or .NET.
> You can create an object without *specifying* an
> ancestor to descend from, and in both languages
> it will default to using Object as the ancestor.

I'm sorry Brad, but if you are being picky, you need to get your facts 
right :-)

The default ancestor in Delphi is TObject and in .NET it is System.Object.

Joanna

-- 
Joanna Carter [TeamB|http://www.teamb.com]
Consultant Software Engineer
0
Joanna
5/27/2010 4:44:47 PM
I definitely see now that the word interface in the sample code was not actually an "interface" that I have come to know, but actually more of a declaration of the public members that will be in a class. I guess Delphi uses a lot of words instead of symbols and this is a case where two words mean the same thing.
0
Eric
5/27/2010 10:59:47 PM
Le 27/05/10 23:59, Eric Painley a écrit :

> I definitely see now that the word interface in the sample code was
> not actually an "interface" that I have come to know, but actually
> more of a declaration of the public members that will be in a class.
> I guess Delphi uses a lot of words instead of symbols and this is a
> case where two words mean the same thing.

You got it! There's a load of tutorials and samples on the web.

Joanna

-- 
Joanna Carter [TeamB|http://www.teamb.com]
Consultant Software Engineer
0
Joanna
5/27/2010 11:16:14 PM
> {quote:title=Joanna Carter wrote:}{quote}
> Le 27/05/10 23:59, Eric Painley a écrit :
> > I definitely see now that the word interface in the sample code was
> > not actually an "interface" that I have come to know, but actually
> > more of a declaration of the public members that will be in a class.
> > I guess Delphi uses a lot of words instead of symbols and this is a
> > case where two words mean the same thing.
> 
> You got it! There's a load of tutorials and samples on the web.

Even though Joanna responded in the affirmative, I wonder if Eric actually should have stated that this is a case where the word "interface" has two different meanings.

If not, then I'm really confused.
--
Rick Carter
Chair, Delphi/Paradox SIG, Cincinnati PC Users Group
0
Rick
5/28/2010 6:56:52 AM
Reply:

Similar Artilces:

Delphi and Delphi for .Net
It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. I would like to know is it true all .Net application is slower than Win32 native applicaiton or it is Delphi for .Net only. Your information is great appreciated, Inung On 2011-06-21 18:20:17 +0100, Inung Huang said: > It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. > I would like to know is it true all .Net application is slower than > Win32 native applicaiton or it is Delphi for .Net only. If you are only running the code in the application once then, yes, yo...

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

DevArchive.com
Hi everybody, DevArchive.com now has new Books section with fresh content - as newest as well as best seller books in .NET, Delphi, Java etc. development, Database administration and development etc. Please check out.---http://www.devarchive.com - .NET, Delphi, Java, VB resources for software developers and IT professionals Here's a link to the guy's site: Link Very funny. Very. Is this unmoderated forum for any discussions? Doesn't DevArchive have any sence for software developers? Did I use any automated software to post this topic? I'm very interested in any feedback about our r...

Delphi developers who are also Python developers [Edit]
I'm interested in knowing how many Delphi developers here also have expert level skills in Python/Django web-framework and use the same in production / at work? How long did it take you to get started and then up and running? What were the best resources that helped in learning learn Python/Django? What are the difficult topics to master? I'm applying for a job here in Nigeria that requires Python/Django, but have only PHP (and some Zend framework) skills. I'm wondering how quickly I will be able to pick up Python and then get up and running with Django. -- Steve...

Api to skydrive delphi or delphi.net
Dear Good afternoon ... Does anyone have any idea or some documentation on how to implement or delphi.net via delphi api to access skydrive files. Thank you for your help. ...

converting delphi code to delphi .NET
Hi,I'm looking at converting quite a bit of old delphi code to delphi .NET .  I'm wondering can it be converted to VB.NET for certain ?  Or perhaps there are some unsupported functions etc in delphi and I should keep the code delphi ?  There are about 10,000 lines of code.   Anyone brave enough to take an estimate on how long it would take to convert 10,000 lines ?is going from delphi to delphi.NET smooth ?   Would going to another language cause complications ?Thanks! mike123   Mike123,   Sorry I can not help, however, I have the s...

Delphi.NET loading Delphi.Win32 Driver
Hi, What I'm trying to do is marshal an array of cardinal (or integer) back into managed memory from a win32 dll. I know how to pass managed memory into a win32 dll {code} var aa : array of Integer; Buffer : IntPtr; begin SetLength(aa,2); aa[0] := 1; aa[1] := 80; if not Supports(ExtractFilePath(Application.ExeName)+'Win32_Library\SDK_Driver.Win32.io', TypeOf(IMyFunctions), MyFunctions) then Exit; //loads the driver into memory. MyFunctions contains the method names found in the SDK_Driver. Buffer := Marshal.AllocHGlobal(2 * {Marshal.SystemDefaultC...

New to Delphi
Hi I am new to Delphi & want to know good resources for learning to use it. Is there a list of good Delphi learning resources (books/online tutorials) somewhere? What recommendations can anyone make for someone new to Delphi (& only a hobby programmer at the moment)? A couple of weeks ago I started with DelphiXE4 trial & have Googled for a few Delphi resources but I haven't found anything very good yet for me as a beginner. I'm just struggling along trying to learn as I go! (I'm presently struggling with DragandDrop...see [http://stackoverflow.com/questions/17232...

Convert Delphi 7 to Delphi 2009 [Edit]
Hi! Please, I have a code done in Delphi 7... Now I want to convert Delphi 7 to Delphi 2009 but I'm having problems when compile the code. Error message: +[DCC Fatal Error] Far.dpr(9): F2063 Could not compile used unit 'System.pas'+ Please can somebody help me? Source Download (349KB): http://rapidshare.com/files/256191328/FileManager.rar.html Mirror Source Download: http://www.megaupload.com/?d=12GYLPT0 Password: delphi Thank u so much! (sorry for my bad english, it is not my native language) Edited by: loquax loquax on Jul 15, 2009 12:24 PM Sorry, bu...

delphi.Net Delphi 2005 Project Upgrades?
Our company aquired the software property from another last year. Most of the projects were written in Delphi 2007. We purchased Delphi XE which gave us access to previous versions, including D 2007... all is well. However, 3 projects were written Delphi 2005 for .Net. The VM we received from this company included D2005 but it was licensed from the previous developer. I've contacted Embarcadero about obtaining a copy and or a license+registration for Delphi 2005 and was told this product is no longer available. I'm under the impression Delphi for .Net was abandoned. My qu...

Converting Delphi for Win32 to Delphi .Net(Prism)
Hi, I am currently migrating a project from Delphi for Win32 to Delphi.net. Part of my code currently goes into a directory and pulls out a random file from this directory and loads the contents of the file for me. This code doesn't seem to work in Delphi.Net. It uses PString and a number of functions in SysUtils that don't seem to be present in Delphi.net's SysUtils file. If anyone can help me please, it would be greatly appreciated! Many thanks, Jonathan Mackey Jonathan Mackey a écrit : > I am currently migrating a project from Delphi for Win32 to &...

delphi Win32 using delphi .NET dll
Hi, I'm trying to use a delphi.NET dll in delphi.WIN32. I am currently using CodeGear Delphi 2007 with version2(base version) of .NET I can get the dll to import into the WIN32 application the only problem is when i include things such as: "using Classes,DateUtils, SysUtils" in the .NET dll the win32 application will instantly hang when any of the dll functions are called. Any help would be great thanks. Also I have tried this example and it also crashes for me? http://cc.embarcadero.com/Item/22688 -Braden I also found this.. "The problem is that, wehn you instal...

Is dll developed in Delphi 6 works on Delphi 2?
I have a one dll, whose work is to creates a form with some normal vcl controls, print selected tables and email some reports. It was developed in Delphi 6. Can any other application which was developed in Delphi 2 use that dll.? If not, please let me know in which areas i need change. The dll work is only to print and email. With regards, Srikanth Varma Srikanth varma wrote: > I have a one dll, whose work is to creates a form with some normal > vcl controls, print selected tables and email some reports. It was > developed in Delphi 6. Can any other application which was d...

Migrating from Delphi 6 to Delphi XE 3! [Edit]
All, I am a Delphi developer working in an windows form application developed using Delphi 6. Now, we are planning to upgrade the development tool. Can anyone provide me information related to major roadblocks that we can face while migrating from Delphi 6 to Delphi XE 3? Should we migrate to Delphi XE 3 or any other preferred version of Delphi based on the fact that our target users will be using Windows 7 or Windows 8? Do we have any tools or utilities to migrate the source code from Delphi 6 to higher version of Delphi? Also, any suggestions related to best practices are welcome....

Web resources about - Delphi for a VB.NET developer [Edit] - embarcadero.delphi.non-tech

Dungeons and developers
Have you ever wanted to learn web development or just refine your webdev skills? Dungeons and Developers gives your quest for knowledge a role ...

Video game developer - Wikipedia, the free encyclopedia
A video game developer is a software developer (a business or an individual) that creates video games . A developer may specialize in a certain ...

Barangaroo: Crowne Plaza bound for Darling Harbour as developers tackle room shortage
The 160-room luxury hotel will take advantage of the inflow of people to the Barangaroo precinct.

Twitter announces native video support for its Twitter Kit developer tool
Twitter today announced that it is rolling out a highly-welcomed new feature to its Twitter Kit developer tools. The company announced in a blog ...

Apple also releases tvOS 9.1 beta 3 for developers
... Apple has also released a new beta update for its fourth-generation Apple TV set-top box: tvOS 9.1 beta 3. Provided you’re a registered developer, ...

Mozilla launches new JavaScript-based Add-ons Validator for developers
... store, browser add-ons have to go through validation to ensure that they work properly and are secure. This is the case with Firefox, and developers ...

Apple seeds tvOS 9.1 beta 3 to developers
... TV just took one step closer to its public release with the third beta build of tvOS 9.1. Apple’s latest tvOS 9.1 beta is available to developers ...

Killing Floor 2 is getting review bombed after developer adds cosmetic microtransactions
... of content updates thus far; they see this as an inappropriate prioritization of company resources and time. Creasy says that " Backend developers ...

Taiwan-based Google Play app developers double in 2 years
The number of Taiwan-based app developers registered on Google Play increased by 200% in the past two years, while the money spent by users outside ...

Watch live streamers play developers at their own games for charity
Erin Robinson Swink, developer of the hand-painted space-physics game, Gravity Ghost, has a simple reason driving her passion for green energy ...

Resources last updated: 11/25/2015 6:03:37 PM