[PHP] Re: PHP, OOP and AJAX
One final update. The way one sets the path to required files is very important. I found it is best to use instead of relative paths. Regards Julian On Fri, Jun 5, 2009 at 2:19 PM, Julian Muscat Doublesin < opensourc...@gmail.com> wrote: > Update. > > Hello Everyone, > > First of all, thank you all for your input. I ran a sinmple test using the > suggestions you gave me and and require_once. > > Using firebug to test the output, I got an internal server error. I found > out what the problem was. > > What I am doing is I have classes which represent the objects, another > class containing the functions. From the function class I create an instance > of each object, manipulate the information, return the HTML result. Finally > I have a runner class that creates an instance of the function class, calls > the function required and outputs the information. > > What the problem was for some reason I was did not create an instance of > the function class, just was calling the function. Well by creating the > runner class I solved the problem. > > Thanks all for your help. > > Regards > > Julian >
Re: Re: [PHP] Re: PHP, OOP and AJAX
On Thu, May 28, 2009 at 2:42 PM, Eddie Drapkin wrote: > autoloading doesn't do anything but follow a set of logic rules to decide > what file to require, so it doesn't mess with opcode caches at all. umm.., right, but what do you think happens at the center of that logic ? require / include calls. which obviously hits the opcode cache, if one is running. i did however draw an inaccurate equivalence between dynamic loading and autoloading, which is a misnomer, since dynamic loading such as $this->load() in ci must be done explicitly, whereas the autoloader will do those lookups on your behalf when needed. its a step beyond $this->load() really. essentially all ci is doing for a performance boost is something like this case 1 case 2 (ci style)
Re: Re: [PHP] Re: PHP, OOP and AJAX
autoloading doesn't do anything but follow a set of logic rules to decide what file to require, so it doesn't mess with opcode caches at all. On Thu, May 28, 2009 at 4:02 PM, Nathan Nobbe wrote: > On Thu, May 28, 2009 at 9:25 AM, Tony Marston < > t...@marston-home.demon.co.uk > > wrote: > > > > > "Eddie Drapkin" wrote in message > > news:68de37340905280801m6964d355l2d6d8ef773f3b...@mail.gmail.com... > > > There's a huge difference between laziness and opting in to use an > > > incredibly useful (and easy to properly deploy) feature to save myself > > > time > > > so that I can spend more time writing that structured and efficient > code > > > of > > > which you speak. And the problem with what you're saying is that you > > > still > > > have to include 'singleton.php' somewhere in order to call its static > > > methods, > > > > I have a single general purpose include file which autmatically includes > > all > > other standard files, so I never have to explicity load my singleton > class. > > > > > and I'd rather just spend 30 minutes writing an autoloader object > > > and letting it deal with finding any of the classes I use then trying > to > > > keep track of legacy code I didn't write and require'ing them all over > > the > > > place. > > > > I'd rather not waste 30 minutes of my time writing a feature that I don't > > need. > > > > The difference between using and not using the autoload feature does not > > have any measurable impact on either my development times, nor the > > execution > > of my code, so I choose to not use it. That's my choice, and I'm sticking > > to > > it. > > > > > The way I look at it, if you spend all your time handling things that > you > > > could automate - and if written properly, will always work as expected > > > (it's > > > called unit testing and debugging) - then you have no time to write > that > > > structured and efficient code in order to meet your deadlines! :) > > > > Not using autoload does not have any noticeable effect on my deadlines, > so > > I > > have no incentive to use it. Just because you say that I *should* use it > > carries no weight at all. > > > this simple fact is that autoloading is something anyone can implement > themselves. take a look at code igniters $this->load() arrangement. > basically they do dynamic loading rather than requires, and thats part of > the reason for the massive performance advantage it has over other > frameworks. > > autoloading is nice because it affords a somewhat standard approach to a > common issue. sure, you could do something like ci, but i say why bother, > why not just use __autoload() and freinds now that php offers it as a > feature. then again, if you already have some dynamic loading system, of > course theres no real call to move to __autoload(). (and of course ci is > written w/ php4 support in mind, which obviously eliminates __autoload in > their scenario) > > im also skeptical of the advantages dynamic loading offers in systems > running an opcode cache. essentially after initially caching a scripts > opcodes, successive include/require calls are a hit to the cache to see its > already there. im sure dynamic loading is offers dramatic performance > gains > systems not running opcode caches though. > > -nathan >
Re: Re: [PHP] Re: PHP, OOP and AJAX
On Thu, May 28, 2009 at 9:25 AM, Tony Marston wrote: > > "Eddie Drapkin" wrote in message > news:68de37340905280801m6964d355l2d6d8ef773f3b...@mail.gmail.com... > > There's a huge difference between laziness and opting in to use an > > incredibly useful (and easy to properly deploy) feature to save myself > > time > > so that I can spend more time writing that structured and efficient code > > of > > which you speak. And the problem with what you're saying is that you > > still > > have to include 'singleton.php' somewhere in order to call its static > > methods, > > I have a single general purpose include file which autmatically includes > all > other standard files, so I never have to explicity load my singleton class. > > > and I'd rather just spend 30 minutes writing an autoloader object > > and letting it deal with finding any of the classes I use then trying to > > keep track of legacy code I didn't write and require'ing them all over > the > > place. > > I'd rather not waste 30 minutes of my time writing a feature that I don't > need. > > The difference between using and not using the autoload feature does not > have any measurable impact on either my development times, nor the > execution > of my code, so I choose to not use it. That's my choice, and I'm sticking > to > it. > > > The way I look at it, if you spend all your time handling things that you > > could automate - and if written properly, will always work as expected > > (it's > > called unit testing and debugging) - then you have no time to write that > > structured and efficient code in order to meet your deadlines! :) > > Not using autoload does not have any noticeable effect on my deadlines, so > I > have no incentive to use it. Just because you say that I *should* use it > carries no weight at all. this simple fact is that autoloading is something anyone can implement themselves. take a look at code igniters $this->load() arrangement. basically they do dynamic loading rather than requires, and thats part of the reason for the massive performance advantage it has over other frameworks. autoloading is nice because it affords a somewhat standard approach to a common issue. sure, you could do something like ci, but i say why bother, why not just use __autoload() and freinds now that php offers it as a feature. then again, if you already have some dynamic loading system, of course theres no real call to move to __autoload(). (and of course ci is written w/ php4 support in mind, which obviously eliminates __autoload in their scenario) im also skeptical of the advantages dynamic loading offers in systems running an opcode cache. essentially after initially caching a scripts opcodes, successive include/require calls are a hit to the cache to see its already there. im sure dynamic loading is offers dramatic performance gains systems not running opcode caches though. -nathan
Re: [PHP] Re: PHP, OOP and AJAX
On Thu, 2009-05-28 at 16:17 +0300, Olexandr Heneralov wrote: > Hi! > Do not use low-level AJAX. > There are many frameworks for ajax (JQUERY). > Try to use PHP frameworks like symfony, zend framework. They simplify your > work. > > > 2009/5/28 Lenin > > > 2009/5/28 kranthi > > > > > > > > > > > i recommend you firebug firefox adddon (just go to the net tab and you > > > can see all the details of the communication between client and > > > server) > > > and i find it helpful to use a standard javascript(jQuery in my case) > > > library instead of highly limited plain javascript language > > > > > I also recommend using FirePHP with FireBug here's a nicely written > > tutorial > > on how to use them both together for Ajax'ed pages. http://tr.im/iyvl > > Thanks > > Lenin > > www.twitter.com/nine_L > > Real coders use low-level ajax... and code with rocks too ;) Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Re: PHP, OOP and AJAX
"Eddie Drapkin" wrote in message news:68de37340905280801m6964d355l2d6d8ef773f3b...@mail.gmail.com... > There's a huge difference between laziness and opting in to use an > incredibly useful (and easy to properly deploy) feature to save myself > time > so that I can spend more time writing that structured and efficient code > of > which you speak. And the problem with what you're saying is that you > still > have to include 'singleton.php' somewhere in order to call its static > methods, I have a single general purpose include file which autmatically includes all other standard files, so I never have to explicity load my singleton class. > and I'd rather just spend 30 minutes writing an autoloader object > and letting it deal with finding any of the classes I use then trying to > keep track of legacy code I didn't write and require'ing them all over the > place. I'd rather not waste 30 minutes of my time writing a feature that I don't need. The difference between using and not using the autoload feature does not have any measurable impact on either my development times, nor the execution of my code, so I choose to not use it. That's my choice, and I'm sticking to it. > The way I look at it, if you spend all your time handling things that you > could automate - and if written properly, will always work as expected > (it's > called unit testing and debugging) - then you have no time to write that > structured and efficient code in order to meet your deadlines! :) Not using autoload does not have any noticeable effect on my deadlines, so I have no incentive to use it. Just because you say that I *should* use it carries no weight at all. -- Tony Marston http://www.tonymarston.net http://www.radicore.org > On Thu, May 28, 2009 at 10:53 AM, Tony Marston < > t...@marston-home.demon.co.uk> wrote: > >> "Eddie Drapkin" wrote in message >> news:68de37340905280737t3e1ad844y188ab8fa08f17...@mail.gmail.com... >> > Your code might not, but you sure do! Spending all that time writing >> > require statements = :( >> >> If you are too lazy to write "require" statements then you are probably >> too >> lazy to write readable, well structured and efficient code. Besides, I >> don't >> use "require" statements, I use >>$dbobject =& singleton::getInstance('classname'); >> >> I don't use autoload because *I* want to be in control. I prefer not to >> rely >> on automatuic features which may not work as expected. >> >> -- >> Tony Marston >> http://www.tonymarston.net >> http://www.radicore.org >> >> > On Thu, May 28, 2009 at 9:49 AM, Tony Marston >> > > >> wrote: >> > >> >> >> >> wrote in message >> >> news:000e0cd6ad1a9f7d3d046af89...@google.com... >> >> > Two things: >> >> > >> >> > 1. Try using the fully qualified path (ie /var/www/foo/bar.php >> >> > instead >> >> > of >> >> > foo/bar.php) >> >> > 2. Look at setting up autoloading so you don't need to manually >> include >> >> > anyway. If you're going OOP, autoloading is a must! >> >> >> >> I totally disagree. I have been doing OOP with PHP for years, and I >> >> have >> >> never used autoloading. It is just a feature that can be used, misused >> or >> >> abused just like any other. I choose not to use it, and my code does >> >> not >> >> suffer in the least! >> >> >> >> -- >> >> Tony Marston >> >> http://www.tonymarston.net >> >> http://www.radicore.org >> >> >> >> >> >> >> >> >> >> -- >> >> PHP General Mailing List (http://www.php.net/) >> >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> >> >> >> > >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Re: PHP, OOP and AJAX
There's a huge difference between laziness and opting in to use an incredibly useful (and easy to properly deploy) feature to save myself time so that I can spend more time writing that structured and efficient code of which you speak. And the problem with what you're saying is that you still have to include 'singleton.php' somewhere in order to call its static methods, and I'd rather just spend 30 minutes writing an autoloader object and letting it deal with finding any of the classes I use then trying to keep track of legacy code I didn't write and require'ing them all over the place. The way I look at it, if you spend all your time handling things that you could automate - and if written properly, will always work as expected (it's called unit testing and debugging) - then you have no time to write that structured and efficient code in order to meet your deadlines! :) On Thu, May 28, 2009 at 10:53 AM, Tony Marston < t...@marston-home.demon.co.uk> wrote: > "Eddie Drapkin" wrote in message > news:68de37340905280737t3e1ad844y188ab8fa08f17...@mail.gmail.com... > > Your code might not, but you sure do! Spending all that time writing > > require statements = :( > > If you are too lazy to write "require" statements then you are probably too > lazy to write readable, well structured and efficient code. Besides, I > don't > use "require" statements, I use >$dbobject =& singleton::getInstance('classname'); > > I don't use autoload because *I* want to be in control. I prefer not to > rely > on automatuic features which may not work as expected. > > -- > Tony Marston > http://www.tonymarston.net > http://www.radicore.org > > > On Thu, May 28, 2009 at 9:49 AM, Tony Marston > > >> wrote: > > > >> > >> wrote in message > >> news:000e0cd6ad1a9f7d3d046af89...@google.com... > >> > Two things: > >> > > >> > 1. Try using the fully qualified path (ie /var/www/foo/bar.php instead > >> > of > >> > foo/bar.php) > >> > 2. Look at setting up autoloading so you don't need to manually > include > >> > anyway. If you're going OOP, autoloading is a must! > >> > >> I totally disagree. I have been doing OOP with PHP for years, and I have > >> never used autoloading. It is just a feature that can be used, misused > or > >> abused just like any other. I choose not to use it, and my code does not > >> suffer in the least! > >> > >> -- > >> Tony Marston > >> http://www.tonymarston.net > >> http://www.radicore.org > >> > >> > >> > >> > >> -- > >> PHP General Mailing List (http://www.php.net/) > >> To unsubscribe, visit: http://www.php.net/unsub.php > >> > >> > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: Re: [PHP] Re: PHP, OOP and AJAX
"Eddie Drapkin" wrote in message news:68de37340905280737t3e1ad844y188ab8fa08f17...@mail.gmail.com... > Your code might not, but you sure do! Spending all that time writing > require statements = :( If you are too lazy to write "require" statements then you are probably too lazy to write readable, well structured and efficient code. Besides, I don't use "require" statements, I use $dbobject =& singleton::getInstance('classname'); I don't use autoload because *I* want to be in control. I prefer not to rely on automatuic features which may not work as expected. -- Tony Marston http://www.tonymarston.net http://www.radicore.org > On Thu, May 28, 2009 at 9:49 AM, Tony Marston > > wrote: > >> >> wrote in message >> news:000e0cd6ad1a9f7d3d046af89...@google.com... >> > Two things: >> > >> > 1. Try using the fully qualified path (ie /var/www/foo/bar.php instead >> > of >> > foo/bar.php) >> > 2. Look at setting up autoloading so you don't need to manually include >> > anyway. If you're going OOP, autoloading is a must! >> >> I totally disagree. I have been doing OOP with PHP for years, and I have >> never used autoloading. It is just a feature that can be used, misused or >> abused just like any other. I choose not to use it, and my code does not >> suffer in the least! >> >> -- >> Tony Marston >> http://www.tonymarston.net >> http://www.radicore.org >> >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Re: PHP, OOP and AJAX
Your code might not, but you sure do! Spending all that time writing require statements = :( On Thu, May 28, 2009 at 9:49 AM, Tony Marston wrote: > > wrote in message > news:000e0cd6ad1a9f7d3d046af89...@google.com... > > Two things: > > > > 1. Try using the fully qualified path (ie /var/www/foo/bar.php instead of > > foo/bar.php) > > 2. Look at setting up autoloading so you don't need to manually include > > anyway. If you're going OOP, autoloading is a must! > > I totally disagree. I have been doing OOP with PHP for years, and I have > never used autoloading. It is just a feature that can be used, misused or > abused just like any other. I choose not to use it, and my code does not > suffer in the least! > > -- > Tony Marston > http://www.tonymarston.net > http://www.radicore.org > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: Re: [PHP] Re: PHP, OOP and AJAX
wrote in message news:000e0cd6ad1a9f7d3d046af89...@google.com... > Two things: > > 1. Try using the fully qualified path (ie /var/www/foo/bar.php instead of > foo/bar.php) > 2. Look at setting up autoloading so you don't need to manually include > anyway. If you're going OOP, autoloading is a must! I totally disagree. I have been doing OOP with PHP for years, and I have never used autoloading. It is just a feature that can be used, misused or abused just like any other. I choose not to use it, and my code does not suffer in the least! -- Tony Marston http://www.tonymarston.net http://www.radicore.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP, OOP and AJAX
2009/5/28 Olexandr Heneralov > Hi! > Do not use low-level AJAX. > There are many frameworks for ajax (JQUERY). > Try to use PHP frameworks like symfony, zend framework. They simplify your > work. > > > 2009/5/28 Lenin > > > 2009/5/28 kranthi > > > > > > > > > > > i recommend you firebug firefox adddon (just go to the net tab and you > > > can see all the details of the communication between client and > > > server) > > > and i find it helpful to use a standard javascript(jQuery in my case) > > > library instead of highly limited plain javascript language > > > > > I also recommend using FirePHP with FireBug here's a nicely written > > tutorial > > on how to use them both together for Ajax'ed pages. http://tr.im/iyvl > > Thanks > > Lenin > > www.twitter.com/nine_L > > > Moo, I would say learn to do PHP by itself before you go using frameworks. AJAX is a bit different though because there will be few reasons that you will ever need to write low level code when you're using a library like Prototype =) -- Luke Slater :O)
Re: [PHP] Re: PHP, OOP and AJAX
Hi! Do not use low-level AJAX. There are many frameworks for ajax (JQUERY). Try to use PHP frameworks like symfony, zend framework. They simplify your work. 2009/5/28 Lenin > 2009/5/28 kranthi > > > > > > > i recommend you firebug firefox adddon (just go to the net tab and you > > can see all the details of the communication between client and > > server) > > and i find it helpful to use a standard javascript(jQuery in my case) > > library instead of highly limited plain javascript language > > > I also recommend using FirePHP with FireBug here's a nicely written > tutorial > on how to use them both together for Ajax'ed pages. http://tr.im/iyvl > Thanks > Lenin > www.twitter.com/nine_L >
Re: [PHP] Re: PHP, OOP and AJAX
2009/5/28 kranthi > > > i recommend you firebug firefox adddon (just go to the net tab and you > can see all the details of the communication between client and > server) > and i find it helpful to use a standard javascript(jQuery in my case) > library instead of highly limited plain javascript language > I also recommend using FirePHP with FireBug here's a nicely written tutorial on how to use them both together for Ajax'ed pages. http://tr.im/iyvl Thanks Lenin www.twitter.com/nine_L
Re: Re: [PHP] Re: PHP, OOP and AJAX
Two things: 1. Try using the fully qualified path (ie /var/www/foo/bar.php instead of foo/bar.php) 2. Look at setting up autoloading so you don't need to manually include anyway. If you're going OOP, autoloading is a must! On May 28, 2009 8:49am, kranthi wrote: i never faced such a problem and i can assure you that it will never happen. try... main.php require('second.php'); ?> second.php test call main.php via AJAX and see the responseText. many things can go wrong in your coding. dont come to the conclusion that this particular thing is not working. i recommend you firebug firefox adddon (just go to the net tab and you can see all the details of the communication between client and server) and i find it helpful to use a standard javascript(jQuery in my case) library instead of highly limited plain javascript language and for you case its difficult to comment without seeing your actual code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP, OOP and AJAX
i never faced such a problem and i can assure you that it will never happen. try... main.php second.php test call main.php via AJAX and see the responseText. many things can go wrong in your coding. dont come to the conclusion that this particular thing is not working. i recommend you firebug firefox adddon (just go to the net tab and you can see all the details of the communication between client and server) and i find it helpful to use a standard javascript(jQuery in my case) library instead of highly limited plain javascript language and for you case its difficult to comment without seeing your actual code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP, OOP and AJAX
Julian, could you please show us an example of this problem? -- João Cândido de Souza Neto SIENS SOLUÃÃES EM GESTÃO DE NEGÃCIOS Fone: (0XX41) 3033-3636 - JS www.siens.com.br "Julian Muscat Doublesin" escreveu na mensagem news:5e0039ed0905280431o2e9d8036u217b0449eccd...@mail.gmail.com... > Hi Everyone, > > This is the first time that I am posting in the PHP forum, so hope that I > am > osting in the right place. > > I would like to say that before submitting to this forum I have done some > research looking for a solution without success. > > I had been programming in ASP.NET for years using Object Oriented > Princeliness but decided to walk away from that. I am now researching and > specialising in the open source world. > > I have started to develop a project using MySQL, PHP and OOP. So far I > have > succeed. However I got stuck once I started implement AJAX using the AJAX > tutorial from w3schools.com. > > What I have discovered is: for some reason when you call a file that > requires other fies using the REQUIRE or INCLUDE it just does not work. I > can conform this as I have tested with out the the functions. > > Has anyone ever meet such a situation can you give me some feedback > please. > > Thank you very much in advance for your support. > > Regards > > Julian > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP OOP
I don't think that PHP is good language for teaching OOP as many folks above said. I have never programmed in OOP style but i plan to learn it. I started in PHP but i was little confused and i am used to program in procedural way in PHP, so i've decided to learn some pure OOP language. I am reading a book OOP Demystified, there are examples in both C++ and Java. And imo Java code is much more readable and understandable. So i think that Java is the best for learning OOP. I am also considering learning C#, if you dont mind that it's closely related to windows, it might be also a good choice. -- "tedd" píse v diskusním príspevku news:p0624080dc5b5fff1c...@[192.168.1.101]... > Hi gang: > > At the college where I teach, they are considering teaching OOP, but they > don't want to settle on a specific language. > > My thoughts are it's difficult to teach OOP without a language -- > while the general concepts of OOP are interesting, people need to see how > concepts are applied to understand how they work -- thus I think a > specific language is required > > I lean toward C++ because I wrote in it for a few years AND C++ appears to > be the most common, widespread, and popular OOP language. > > However, while I don't know PHP OOP, I am open to considering it because > of the proliferation of web based applications. My personal opinion is > that's where all programming is headed anyway, but that's just my opinion. > > With that said, what's the differences and advantages/disadvantages > between C++ and PHP OOP? > > Cheers, > > tedd > > > -- > --- > http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP OOP x Procedural Performance
Hi, From my personal recent experience, I can tell you that processing a lot of echo's thru classes is a heck of a lot slower than just doing it the normal way. Although I wouldn't have done this particular project any other way, I do with that I could get it to display faster. Its not a big deal, just bugs me. Its really personal preference though. -Dan Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP OOP x Procedural Performance
"Joe Stump" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Sure ... > > I'm of the belief that OOP (in PHP anyways) has great use for core > libraries. Core libraries, by their nature, generally don't output HTML. > It's a core libraries job to separate logic and presentation. How portable > is your library that outputs HTML for a guy who wants PDF/WAP/XML output? > > For instance, I have a product class that does various things to format > product *data* prior to my procedural scripts putting it into my Smarty > templates. If that product class outputted the data in HTML it would be > useless to me for WAP users or a script that generated PDF versions of our > online catalog. Core libraries are of course first candidate for OOP, but I think there are many other places where you can use it successfully. Take for instance how it is used in TemplateTamer. In it, you define a class responsible for the generation of the page. In typicall usage you have a common class that all page classes inherit from, and which defines elements of page common to all pages on the site, and specific page classes implement only the parts they differ in. When the site grows, it is common to refine the hierarchy of page classes, so you have one page class on the top, then a few below it describing main sections of the site, and then on the bottom concrete page classes. Another OOP usage in TT can be in creating classes that represent GUI components. For instance on one site I have worked, I have created a JobAdForm object, that handles for reponsible displaying form and editing of JobAd object. Than when I needed similar but litle more extended version for superuser pages, I have just created a subclass SuperuserJobAdForm, and overided necessary parts, but inhertied 95% of code. So I think there is usage for OOP also in "gui" parts of the code, where it can also help better organization of code, and reuse between the pages or components on the same site. rush -- http://www.templatetamer.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP OOP x Procedural Performance
Joe, I mostly agree with your opinion. But remember that a method in an object that has output doesn't have to print the output - it can return it instead and the calling function can then either display the output or do something else with it. And if it makes sense to have a method return HTML, another developer can override that method so that it returns XML. Or yet another method could take the HTML output of the first one and convert it to PDF. The question, I think, is about figuring out the most effective place to do what solves the problems. I'm afraid that saying "You should never ever ever write an OOP method that has HTML in it's output" is so rigid that it might make the development process more difficult and complex than it needs to be. Michael On Thu, 2003-05-29 at 11:28, Joe Stump wrote: > Sure ... > > I'm of the belief that OOP (in PHP anyways) has great use for core > libraries. Core libraries, by their nature, generally don't output HTML. > It's a core libraries job to separate logic and presentation. How portable > is your library that outputs HTML for a guy who wants PDF/WAP/XML output? > > For instance, I have a product class that does various things to format > product *data* prior to my procedural scripts putting it into my Smarty > templates. If that product class outputted the data in HTML it would be > useless to me for WAP users or a script that generated PDF versions of our > online catalog. > > --Joe > > > -Original Message- > From: Johnson, Kirk [mailto:[EMAIL PROTECTED] > Sent: Thursday, May 29, 2003 8:21 AM > To: 'Joe Stump'; [EMAIL PROTECTED] > Subject: RE: [PHP] Re: PHP OOP x Procedural Performance > > > > One thing I'd like to abundantly point out is that NOT > > EVERYTHING BELONGS IN > > OOP! For instance, if you're building classes that output > > HTML - you've > > skipped a few chapters in your OOP design books. > > Joe, > > I am curious about this opinion, could you elaborate a bit, please? I am not > an OOP programmer, and I'm just interested in your thoughts on this, if you > have time. > > Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP OOP x Procedural Performance
Sure ... I'm of the belief that OOP (in PHP anyways) has great use for core libraries. Core libraries, by their nature, generally don't output HTML. It's a core libraries job to separate logic and presentation. How portable is your library that outputs HTML for a guy who wants PDF/WAP/XML output? For instance, I have a product class that does various things to format product *data* prior to my procedural scripts putting it into my Smarty templates. If that product class outputted the data in HTML it would be useless to me for WAP users or a script that generated PDF versions of our online catalog. --Joe -- Joe Stump <[EMAIL PROTECTED]> http://www.joestump.net "Label makers are proof God wants Sys Admins to be happy." -Original Message- From: Johnson, Kirk [mailto:[EMAIL PROTECTED] Sent: Thursday, May 29, 2003 8:21 AM To: 'Joe Stump'; [EMAIL PROTECTED] Subject: RE: [PHP] Re: PHP OOP x Procedural Performance > One thing I'd like to abundantly point out is that NOT > EVERYTHING BELONGS IN > OOP! For instance, if you're building classes that output > HTML - you've > skipped a few chapters in your OOP design books. Joe, I am curious about this opinion, could you elaborate a bit, please? I am not an OOP programmer, and I'm just interested in your thoughts on this, if you have time. Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP OOP x Procedural Performance
> One thing I'd like to abundantly point out is that NOT > EVERYTHING BELONGS IN > OOP! For instance, if you're building classes that output > HTML - you've > skipped a few chapters in your OOP design books. Joe, I am curious about this opinion, could you elaborate a bit, please? I am not an OOP programmer, and I'm just interested in your thoughts on this, if you have time. Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP OOP x Procedural Performance
In my experience OOP isn't any faster/slower. I've used it on sites that get 30M hits a month; so if it's gonna break I'd have seen it by now. One thing I'd like to abundantly point out is that NOT EVERYTHING BELONGS IN OOP! For instance, if you're building classes that output HTML - you've skipped a few chapters in your OOP design books. OOP with PHP is lacking as far as complex application development (PHP5 looks to fix this), but it works great for base classes. I usually program CORE functionality in OOP (ie. Basket for e-commerce which keeps track of users' baskets). The rest of the code is procedural (ie. code that does basic math and organizes the page). --Joe -- Joe Stump <[EMAIL PROTECTED]> http://www.joestump.net "Label makers are proof God wants Sys Admins to be happy." -Original Message- From: rush [mailto:[EMAIL PROTECTED] Sent: Thursday, May 29, 2003 8:02 AM To: [EMAIL PROTECTED] Subject: [PHP] Re: PHP OOP x Procedural Performance "William N. Zanatta" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > It is a known issue that function calls are expensive for the processor. > > The OOP let us better organize the code but, thinking in function (or > method) calls it may be more expensive than in the procedural form. > > My question is, has anyone made any tests regarding the performance of > OOP versus procedural language? Is it a good choice to code in OOP with > PHP ? I would say, that web app model is so inefficient in itself, that you can hardly do anything to make things significantly worse or better performance wise. Also OOP is extensively used in other environments, and unless you are coding critical device drivers, it is rarely to "expensive" in terms of processing time. So my advice would be use OOP, and take benefit of better organization of your code. Just my 2c. rush -- http://www.templatetamer.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP OOP x Procedural Performance
"William N. Zanatta" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > It is a known issue that function calls are expensive for the processor. > > The OOP let us better organize the code but, thinking in function (or > method) calls it may be more expensive than in the procedural form. > > My question is, has anyone made any tests regarding the performance of > OOP versus procedural language? Is it a good choice to code in OOP with > PHP ? I would say, that web app model is so inefficient in itself, that you can hardly do anything to make things significantly worse or better performance wise. Also OOP is extensively used in other environments, and unless you are coding critical device drivers, it is rarely to "expensive" in terms of processing time. So my advice would be use OOP, and take benefit of better organization of your code. Just my 2c. rush -- http://www.templatetamer.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP OOP design question
Answer - use PEAR for both your database connection and as a data modeling layer: http://pear.php.net check the documentation for more info. neko "Joseph Szobody" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I have several web projects that are all database driven. I have recently been diving into OOP, and rewriting a lot of procedural code in OOP. I have a design question about handling the MySQL connection. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP OOP
Rodrigo Dominguez wrote: >I made a mistake while I was writting the example, in my original code I >wrote it as you did, with $this->b[0] = new one(); but it doesn't work. >Thank you. > >"Philip Hallstrom" <[EMAIL PROTECTED]> escribió en el mensaje >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > >>Not tested, but what if you change >> >> $b[0] = new one(); >> $b[1] = new one(); >> >>to: >> >> $this->b[0] = new one(); >> $this->b[1] = new one(); >> >>On Tue, 3 Sep 2002, Rodrigo Dominguez wrote: >> >> >> >>>I have a problem, I can't create an array of classes into a class, for >>>example: >>> >>>class one { >>>var $a; >>> >>>function foo() { >>>echo "foo"; >>>} >>>} >>> >>>class two { >>>var $b; >>> >>>function initialize() { >>>$b[0] = new one(); >>>$b[1] = new one(); >>>} >>>} >>> >>>$test = new two(); >>>$test->initialize(); >>> >>>$test->b[0]->foo(); //It doesn't work >>>$test->b[1]->foo(); //It doesn't work >>> >>>Any suggestion? >>> >>> >>> >>> >>>-- >>>PHP General Mailing List (http://www.php.net/) >>>To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >>> > > > > > Eh.. unchecked code, but what about: $this->b[0] = new one; $this->b[1] = new one; $test = new two; Instead of $this->b[0] = new one(); $this->b[1] = new one(); $test = new two(); If no luck try to include error_reporting(E_ALL); as first line of your script. Good luck René -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP OOP
I made a mistake while I was writting the example, in my original code I wrote it as you did, with $this->b[0] = new one(); but it doesn't work. Thank you. "Philip Hallstrom" <[EMAIL PROTECTED]> escribió en el mensaje [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Not tested, but what if you change > > $b[0] = new one(); > $b[1] = new one(); > > to: > > $this->b[0] = new one(); > $this->b[1] = new one(); > > On Tue, 3 Sep 2002, Rodrigo Dominguez wrote: > > > I have a problem, I can't create an array of classes into a class, for > > example: > > > > class one { > > var $a; > > > > function foo() { > > echo "foo"; > > } > > } > > > > class two { > > var $b; > > > > function initialize() { > > $b[0] = new one(); > > $b[1] = new one(); > > } > > } > > > > $test = new two(); > > $test->initialize(); > > > > $test->b[0]->foo(); //It doesn't work > > $test->b[1]->foo(); //It doesn't work > > > > Any suggestion? > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP OOP
Not tested, but what if you change $b[0] = new one(); $b[1] = new one(); to: $this->b[0] = new one(); $this->b[1] = new one(); On Tue, 3 Sep 2002, Rodrigo Dominguez wrote: > I have a problem, I can't create an array of classes into a class, for > example: > > class one { > var $a; > > function foo() { > echo "foo"; > } > } > > class two { > var $b; > > function initialize() { > $b[0] = new one(); > $b[1] = new one(); > } > } > > $test = new two(); > $test->initialize(); > > $test->b[0]->foo(); //It doesn't work > $test->b[1]->foo(); //It doesn't work > > Any suggestion? > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP OOP list
Hello, On 07/23/2002 02:35 PM, Mathieu Dumoulin wrote: > Is there a newsgroup list for PHP and OOP? > It would be great to split up this large topic and create an OOP specific > list. Sure, just send a message to [EMAIL PROTECTED] or subscribe in this page: http://groups.yahoo.com/group/php-objects/join -- Regards, Manuel Lemos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php