Re: [PEPr] Call for Comments: Structures_Form
| From: | Scott Mattocks | Date: | Wed, 05 Apr 2006 18:14:09 +0000 |
| Subject: | Re: [PEPr] Call for Comments: Structures_Form | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-42093@lists.php.net to get a copy of this message | ||
Thanks for the feedback.
Justin Patrin wrote:
On 4/4/06, Christian Weiske <cweiske@cweiske.de> wrote:I don't think wrapping all of the PHP-GTK 2 objects is the best way to go here. If I encapsulate all of the PHP-GTK 2 accessing the actual widgets becomes more difficult. The renderer has to call a method on all of the elements to get the widget and the user cannot simply call the widget methods directly. They have to first grab the widget from the element and then call its methods. I know that I could use __call() but I don't think that is as clean as the way I have it done now. The repeated and unchanged methods are *very* simple. I am not really concerned about issues normally associated with duplicated code. Normally when one talks about duplicated code they are concerned with minor changes from implementation to implementation that impact the way the code works. Here all we are talking about is wrappers around set_data() and get_data(). Repeating these seven methods is IMO cleaner than obfuscating everything with __call() and other wrapper methods. Also, the Gtk2 elements are a special case. Other interfaces don't have to be implemented this way. It is just a result of the nature of PHP-GTK 2. An HTML frontend can easily (and most certainly should) inherit from a base class that implements the seven methods once. The way I have architected this package doesn't prevent elements from inheriting from a single base class, it just gives the individual frontends the flexibility to do what is best for the type of display they are designed for. -- Scott Mattocks Author of the soon to be published: Pro PHP-GTK http://www.crisscott.comToo bad that php doesn't allow multiple inheritance - it would have saved lots of repeated setLabel/getLabel/... methods.I'm still worried about this architecture. Common code *should* be broken out and I have no doubt that the Gtk2 elements could benefit from this. Couldn't you use encapsulation for this? Make a base class for your elements, use normal inheritance and such, and have the actual Gtk2 component a member var of the element class?