?
Solved

Delphi as an Object Oriented Language...

Posted on 2003-02-20
10
Medium Priority
?
523 Views
Last Modified: 2013-11-23
Hello!

This question isn't about solving a problem or something like that.  I should probably have posted it in a newsgroup or something but since you guys are actually the best experts on the whole web (!!!), I'll give 50pts to the first 2 of you guys giving me a complete anwser to my question.  OK ? So here it is....

I'm teaching a class on basics of Delphi (loops, arrays, real basics!).  The students are programmers which a used to code VB and some C++.  I presented Delphi as an Object Oriented and some of my students asked me how is Delphi different than C++ regarding Objects.  They seemed to think there was a huge difference between the 2 language (they were kind of splitting Objects in two categories: Delphi's way and the others!)  

The thing is that I always thought that Delphi's way of doing it isn't very different than C++ does.  The only big difference I see is that there is no multiple heritage in Delphi.  

So you see my question comming, aren't you ?  There it is:  what are the difference between Delphi's way of handelling Objects and C++ one ?

Thanks!!
0
Comment
Question by:qas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Accepted Solution

by:
NightAwk earned 200 total points
ID: 7988777
Well i dono really, u see i too was a C++ addept and i tought it was just the best thing ever, then after stubbling a couple of times w memory allocation problems,
i decided to change to delphi, thinking it would be better. I though that because often in the C++ Builder help u see that most of the o-o classes, such as AnsiString, are derived from Delphi classes, so i tought it would automaticly be better.

So after week of translating my code to delphi, i stumbled against the same problems, memory out of bound access and repeated crashes. So u imagine how i kinda felt, so i tried everything to find a colution, seeing that allocating records on the heap (structures in C++) was the source of all my problems, and having no one else to blame but myself (cuz before i switched, i blamed C++, lol) so i tried using TTables and db acess, but those only allow to store one table by file, wich was a big dropback for what i wanted to do (i had about 10 tables).
i am now programming my records into classes, and it seams to be running alot better ... for now.

Anyway what i wanna say is that i did OO before, in Java, i never actually used in in C++, but its about the same i guess, just like its about the same in delphi, and u know for many years now, thanks to Borland, the "owner", almost, of C++ and delphi, they have been progressing paralely, so the technology in both is very similar now, and seriously, i kinda like delphi better.

Well i think u want to know how it works down deep in memory and all, that i dono, but i guess its very similar, that is if u use c++ builder. But the way u work with OO is the same as in C++, and in Java too, O-O really has standards in every language, using objects in c++, pascal or C++ really is the same, well for me at least, aside from the languages differences.

I hope this gives the information u wanted.

Bye.
0
 
LVL 3

Expert Comment

by:sfock
ID: 7988800
well there are no mayor differences between C++ and Delphi regarding how oo works

As much as i know delphi has 2 details it does not support
the first is what you already mentioned the multile heritage of classes(but if you ask me this is not a disadvantage it's an advantage of Delphi because multiple heritage of classes often leds to a bad design and unmaintainable systems) and you are still able to get the same results with better design patterns
and the second one are static variables wich are not supported by delphi. This is sad but true but also not a real problem after you can still simulate the benifits of class variables with unit private variables.
There's nothing more. What your students told you is nothing but usual C++ programmers snobism ... Tell them to give objective reasons for their opinion, they'll not be able to i bet ;-))
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7988811
no much c++ experience,
therefore listening with interest

;-)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:tongalite
ID: 7988850
Hi
Take a look at this....
http://www.gekko-software.nl/DotNet/Art01.htm

Maybe it will be some good to you

Good luck
T.
0
 
LVL 21

Expert Comment

by:ziolko
ID: 7989177
one comment about multple heritage..You can simulate this in Delphi useing interfaces, but its only simulation not real multiple heritage. Now about OO prgraming, object oriented programming is nothing more but the way You design applications and I will be surprised if one day I'll find some major differences between OO in Delphi and other languages. Delphi is great because its RAD (Rapid Application Development) and its RAPID! (I remeber my first "Hello World" app in VC++ with MFC :-) ), but OO is just a method, You design objects and dependencies between them. I'll risk saying that good designed app can be implemented in any OO language, so if You have good project its up to You wich language to use.
ziolko.
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 7989360
In delphi you can't have object created on the stack - they all come from the heap.

In C++ you can do things like

class tSomeClass
{
  ... stuff in here
};

void TestFunction()
{
  tSomeClass X;    // on the stack
  tSomeClass *Y;   // on the heap - need 'new'

  Y = new tSomeClass;
}

where X gets 'freed' automatically.

In delphi, you can't do the first. Eveything is created on the heap and you need to use 'Create' or some other constructor.

So in Delphi, all your objects are actually pointers to objects, which is a little confusing.... especially if you mix them with records which really _are_ proper records on the stack....
0
 
LVL 21

Expert Comment

by:ziolko
ID: 7992108
OO is methodology or if You want philosophy and its got nothing to do with stachs, heaps, constructors or destructors, such details are matter of syntax not methodology.
ziolko.
0
 
LVL 3

Expert Comment

by:sfock
ID: 7992206
andrewjb
one of the biggest benefits of oo programming is that you do _not_ have to think about memory! (Something C(++) programmers do hard with). In the oo-sense there is no stack existing and also no heap! That means it's not a matter of oo or not! To be precise the possibility of choosing a memory segment in C++ breaks an oo-paradiga. Not the opposite!

btw just to add some polemic: It's a matter of C++'s history, that the most C++ programs are not ++ but C+ programs. The fact, that you still have to care for the memory for native types semms to make it very hard to lot's of C(++) programmers to begin to think in an oo way they do still see just bytes everywhere they have to keep track for ;-)

ziolko
oo is not a methodology (while OOM,OOD,OOP, OOSWE or Booch are) but it's a theory. But in the sense i guess you meant it you are totally right: There is no "oo-program" whithout an oo-method and all these stuff has nothing to do with binary memory allocation and such stuff!!!
0
 
LVL 21

Expert Comment

by:ziolko
ID: 7993879
sfock maybe methodology is wrong word, thats due to my poor english :-), but I'm glad You understood what I meant.
ziolko.
0
 

Author Comment

by:qas
ID: 8021772
Thanks alot!

As promised, 50pts will be posted for sfock' answer too.

Thanks again!
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

777 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