sexta-feira, 20 de abril de 2007

Building class objects with PHP-GTK





The main rule to build professional applications on any programming language is to get the maximum outcome from the components that you develop.
On creating classes, we are making object packages that can be called and used in any part of the application and prevent to repeat code.
On this article i will teach how to develop classes using the property parent
To better undertand what we are doing , we need to learn something about object hierarchy.
On GTK , GtkObject is the base of the hierarchy. It means all objects come before it, on a tree style.
On real life you can see it when someone builds a house. The process has a correct order. Nobody starts building a house by the roof. First someone builds the foundations, next the floors, right next the walls and so one.



The image next shows the majory of object hierarchy on PHP-GTK2










The GTK object hirarchy




















Correct object hierarchy disposition








Understand object hirarchy is extremely important , because only this way we sure that our applications and object are used/builded correctly.




As i ment on the top of this article , i will use the PHP property parent.
It is mean that we will work on objects inheritance . To do that the rule is use the reserved word extends and right next reference the superclass .


Example:


class Window extends GtkWindow


Right next follows a pratical example using PHP-GTK





















Follows a short example using the class and the result of code






















the code result









Sem comentários: