Saturday, October 23, 2010

Does multiple inheritance exists in Delphi?

Sometimes it is asked - Delphi supports multiple inheritance or not?

and the answer which usually comes out is - Yes via interfaces, but the problem here is can we really say that implementing an interface actually achieves multiple inheritance in real sense or is it something else. Well the answer to this confusion is that 'No' we cannot say that implementing an interface is a way to achieve multiple inheritance because the first promise that multiple inheritance or inheritance in itself wants is that not only the declaration but also some of the behaviour should get inherited by the child class from the parent class/classes else just by suggesting a declaration of what should be achieved by a child class can never be inheritance. It is as simple as considering the analogy a child inherits some features from both mother and father but its never that a implementation is not inherited from any of the two.

Using interfaces is simply a way of allowing a boundation to the inheriting class to implement certain features so that it meets certain criteria nothing more than that. So the only language to implement multiple inheritance successfully in its real sense is C++ as of now and as per my knowledge. Delphi goes the way Java or C# tried to achieve the similar functionality via interfaces.

Difference between Method pointers and procedural pointers

While I was having some talk with my friends we ended up into a confusion as what exactly is the difference between the method pointers and procedureal pointers in Delphi and how it can be understood well. Well for a seasoned professional may be the answer to it is quiet easy but it took sometime before we really hit on the answer.

Method pointers are basically pointers to a method which is related to a class and as it is related to a class hence Delphi does pass on the 'Self' implicitly to the method so that the object can be referred to within the method pointed to by the method pointer. In case of a procedural pointer this 'Self' is what is missing and hence we can't have a procedural pointer refer to a class method.

This could be easily remembered the way a class method is defined -

MyClass.MyProcedure;

In this was we can see that we actually have MyClass which suggests that MyProcedure belongs to it. A normal procedure would be defined in this way -

MyProcedure;

suggesting that there is no class to which it belongs and hence no 'Self'.

Sunday, June 20, 2010

Is Application Object a window in Delphi?

Often sometimes while working in Delphi I wondered whether the Application object itself is a window or not.. and if so then where exactly is this window and why is it not visible? Going through Marco Cantu's Mastering Delphi book I found that yes infact Application object in delphi is infact a window but than this fact drove me into curiosity to just see this window visibly and hence I thought of programming a bit on this fact. Though Marco suggested that the best way to see that "Application object is infact a window" is to run Delphi, select "New Application" which creates a new windows application and gives Form1 as a default form and then simply press the Run button. Now on looking into the task bar we are see that the title for our new application is getting displayed as Project1 and not Form1 which clearly suggests that there is infact a hidden window in our newly created windows application. This hidden window is none other than very own Application window but still if we could see the window well stretched on our desktop then it would be a better confirmation to this fact after all to see it clearly is better than mearly realising a fact... Am I Correct? So here we go..

Now to start with - first here is a bit of delphi lecture - If we will look at how TApplication has been defined in Delphi then we find that the class has been inherited from TComponent class but than on going through the class definition we find that Application object infact allows programmer to have access to its handle value.. Handle in itself is a unique 32bit (for 32 bit systems) number that windows OS assigns to each window that will be handling any sort of windows messaging.
Once while I was going through some VC++ lessons and VB programming I once read that if we have access to the handle value fo a window we can manipulate that window to the maximum extent via the windows API's and hence I plan here to do the same to make the "Application Object" show its coordinates and make itself visible...

Monday, January 11, 2010

A list of popular applications created in Delphi!

Hi All,

I was going through a lot of discussions in forums and other communities when the discussion turned towards the facts as how many and which popular applications have been created using the Delphi and the answer most were giving was - Skype. Though Skype is indeed a very popular product and ofcourse distributed under Freeware software category however it is not the only product that is popular and has been developed using Delphi. I went through various sites and found a list of such applications created using Delphi. Instead of presenting the same list again at this place here is the link to one such page - http://delphi.wikia.com/wiki/Good_Quality_Applications_Built_With_Delphi
I hope there will be many more such applications that would have been created using this excellent tool but for now above is the list.