Re: DB_DataObject and Structures_DataGrid integration

From: Date: Fri, 13 Aug 2004 14:49:13 +0000
Subject: Re: DB_DataObject and Structures_DataGrid integration
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-32621@lists.php.net to get a copy of this message
Andrew Nagy wrote:
And what about my event-based ideas that you wiped out in your current answer ?
I am still thinking about this :) It is exactly the way .net does it which could be good or bad. To me .net is not intuitive for the app programmer; however, i think the design of .net is very good. So my out look is keep the same premise, just make it easier to use. Using the event based model could add a whole new layer of complexity, but it may be very worthwhile.
The problem with the .NET approach (I'm talking about ASP.NET and its "code behind" paradigm here) is the way events are being used. The ASP.NET architecture is based on the same development paradigm as desktop applications. This was done by Microsoft to make the transition between web and desktop apps easier for the average Windows developer. Of course, this is all based on the assumption that each component on the page, and of course the page itself, is able to throw events and react on them as well. Your page is initialized, and a page_load event is thrown. You can add your own additional initialization code in a method that handles this event (like setting up a DB connection for example). If the page contained a submit button and it had been pressed, a button.clicked event is thrown, which can be handled by you. While this sounds nice, it can lead to serious debugging nightmares and also ties your code to a specific template - this isn't exactly what I would call clean separation of view and business logic... For PHP applications (in an interpreted environment) this also means quite a lot of overhead. My PHP scripts are usually a great deal shorter than a .NET page that can do similar stuff, they're more linear, easier to grasp and to debug, and they provide clean layout/logic separation. Don't get me wrong, event handling isn't a bad thing (as mentioned earlier, I'm about to propose a general package for that in the near future), but in web applications, it shouldn't be used for flow control. This is just plain wrong. Also, this doesn't have anything to do with the idea of making the DataGrid package more flexible through the use of events. If events are feasible (IMHO, in most cases, simple callback methods will do, which have nothing to do with a real event system (see: Observer Pattern)), DataGrid should use them. Just don't try to copy *everything* from .NET - just because something makes sense there, it doesn't mean it makes sense in PHP. The DataGrid component is a good example for a really good component in .NET that should be brought to PHP, but in a PHP way. Using events for flow control in a web application isn't. CU Markus

« previous php.pear.dev (#32621) next »