Re: Is extensive use of classes too much contra-productive?

From: Date: Wed, 12 Nov 2003 23:10:48 +0000
Subject: Re: Is extensive use of classes too much contra-productive?
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-23561@lists.php.net to get a copy of this message
On 12 Nov 2003 at 21:46, Martin Jansen wrote: > On Wed Nov 12, 2003 at 08:0701PM +0100, Stefan Neufeind wrote: > > Should a function be > > $graph->setAxesYFont(...) > > > > or > > > > $graph->axes->y->setFont(...) > > > > ? What do you think? The first uses much less class-complexity while > > the second example has a very clear interface. What I like about the > > second solution is that you can have a method "setFont" for every > > item in your classes - e.g. axes->y->setFont(...) or legend->title- > > >setFont() or whatever. > > > > Somebody raised the assumption that it might be quite slow to use > > multiple classes for the second solution and that it would be *much* > > faster to keep going the way of my first (and current) solution. > > If you are going to split each class (Graph/Graph_Axes/Graph_Axes_Y) > into a separate file and include them in Graph.php, it will be slow as > hell because of the I/O "traffic". > > Having multiple classes in only few files however won't hurt that much > (it still will be considerably slower). And finally creating graphs > does not happen in realtime usually, so performance isn't the most > critical point there. Hi Martin, didn't intend to spit all those small helper-classes off into separate files. It was just an idea to keep the API a bit more clean. Having $graph->axes['y']->setFont(...) or similar seems a bit more clean to me than using $graph->setAxesYFont(...) where you have multiple similar functions with each confusing names. Which solution would you prefer? The really fast solution? Is that API okay also in your eyes? How much do you expect performance to drop? From 0.3 to 0.4 seconds? Or even less extreme? Stefan

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