HGeneAnthony Posted March 28, 2007 Share Posted March 28, 2007 When I write classes I try to make them modular. One thing I like to do is create functions that can be used to grab the data rather than having the classes print the data off itself. This keeps things clean and easier to maintain, makes the code easier to reuse, plus it makes it easier for me to modify the form to change how the output will be displayed later. For example, if I have a list of items to return to the form, rather than having the class print out to the form, I would create functions the form can easily parse to return specific pieces the data. The code on the form is very clean as well as the classes code. The problem is I store the results in a collection until the form grabs it and I was wondering how is this on performance. In a typical desktop app this would be the logical thing to do but with a web server where performance can be hit hard I don't know. Is printing the data off immediately much better on performance. Link to comment https://forums.phpfreaks.com/topic/44591-is-it-bad-on-performance-to-pass-objects-as-opposed-to-printing-them/ Share on other sites More sharing options...
rofl90 Posted March 28, 2007 Share Posted March 28, 2007 Probably, but I wouldn't think it'd make the most difference Link to comment https://forums.phpfreaks.com/topic/44591-is-it-bad-on-performance-to-pass-objects-as-opposed-to-printing-them/#findComment-216583 Share on other sites More sharing options...
dsaba Posted March 28, 2007 Share Posted March 28, 2007 I would only ask this question and want the answer to this question if I am in a situation where my perfomace is INDEED noticably suffering you seem to be in the ....hmmm what if phase, not the "damn my perfomance sucks, what do I do stage?" hence i wouldn't worry about this so much until you do notice it, and if you have never noticed it, well there is your answer (dont' get me wrong asking question are great, but you asked for my opinion-walla) Link to comment https://forums.phpfreaks.com/topic/44591-is-it-bad-on-performance-to-pass-objects-as-opposed-to-printing-them/#findComment-216585 Share on other sites More sharing options...
HGeneAnthony Posted March 28, 2007 Author Share Posted March 28, 2007 In the past I've written php scripts for small companies. The speed has been pretty good since I don't over do it with heavy graphics. My sites are built for performance and navigation rather than an expression of art. What I'm worried about is when I get heavy traffic how it can be affected. Link to comment https://forums.phpfreaks.com/topic/44591-is-it-bad-on-performance-to-pass-objects-as-opposed-to-printing-them/#findComment-216623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.