Spaceman-Spiff Posted May 9, 2008 Share Posted May 9, 2008 We're starting a new project at work, the team only consists of 2 programmer (me and the other guy). The other guy's background is Java and PHP5. My background is more varied from Basic, Pascal, VB, Java, C++, C#, PHP 3, 4, and now starting 5. I have never really coded anything in fully OO in PHP5, aside from modifying/tweaking codes. So far all of my past PHP projects have been procedural. It's the fastest way to code for me. Now, for this project, my co-worker wants everything coded in pure OO. No global variables/declarations at all. It's a decent-sized project with 2-3 months development time. I don't mind to start learning about OO in PHP5, but my main concern is coding in OO style may mean longer development time. Another concern is the code may not perform as fast as it would if coded procedurally. His main argument is coding in OO will make the project more extensible. From my past experiences with Java and C#, OO codes tends to be longer (more total lines of code), thus also take longer to code. It is more "secure" and the code looks prettier (sometimes), is it always worth it? I have read the other topic about this. I do want feedback on this more specific matter. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/ Share on other sites More sharing options...
jcombs_31 Posted May 14, 2008 Share Posted May 14, 2008 It has nothing to do with security or looking pretty. I would say the most fundamental concept is re-usability. That is what Object Oriented Programming great. It also follows a logic that is easy to understand. I also don't think that you should always use OOP. Sometimes it is easier and faster to do small little tasks procedurally. But if you plan to build anything extensive, such as an ecommerce site or CMS, OOP just makes more sense. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-541083 Share on other sites More sharing options...
RichardRotterdam Posted May 15, 2008 Share Posted May 15, 2008 I have to agree with jcombs_31. Mostly i program in oop style cos many classes i use pretty often such as logon classes and formvalidation. because i have them in classes it saved me tons of time creating new cms systems. But some stuff is simply easier to place as a function because you want to use it a lot and not just for one class. So pretty much keep in mind what you are going to build and if something will be usable in the future might as well spend a little more time on it now so you can re-use for future projects. but dont overdo it. php 5 has better oop support compared to php 4 but php != java. and lets keep it that way Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-542104 Share on other sites More sharing options...
448191 Posted May 15, 2008 Share Posted May 15, 2008 The person who voted 'entirely OOP' is a big fat liar It is impossible to code entirely OO with PHP. In fact, I'd even say it is impossible to code entirely OO in any language that isn't fully OO itself. That includes any language with primitive types, including C++, C, C# and Java. You can code entirely OO in Smalltalk and Ruby. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-542177 Share on other sites More sharing options...
Darklink Posted May 23, 2008 Share Posted May 23, 2008 I'm sure when they say 'entirely OOP' they mean as much as possible. Of course you will need to initiate the classes in the first place. I selected 'entirely OOP'. I can't stand to see a script without OOP now. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-548127 Share on other sites More sharing options...
448191 Posted May 23, 2008 Share Posted May 23, 2008 Of course you will need to initiate the classes in the first place. Not to be snobby, but you can't instantiate classes. You can only instantiate objects, of a class (type), using a class. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-548270 Share on other sites More sharing options...
Darklink Posted May 23, 2008 Share Posted May 23, 2008 I said initiate. Initiate is not the same as instantiate. I may of worded it incorrectly anyway. "Class initiation"? I could of just said object instantiation. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-548603 Share on other sites More sharing options...
moon 111 Posted May 25, 2008 Share Posted May 25, 2008 You're right, I lied, my controller isn't OO. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-549500 Share on other sites More sharing options...
keeB Posted June 8, 2008 Share Posted June 8, 2008 I started typing a response, but I ended up posting my thoughts on OOP here: http://nick.stinemates.org/wordpress/ This is about as procedural as my code gets (I dont expect it to make sense, its just an example): <?php require_once("src/php/com/cm/qa/ws/factory/RequestFactory.class.php"); require_once("src/php/com/cm/qa/ws/factory/FileNotFoundException.class.php"); require_once("src/php/com/cm/qa/ws/command/CommandDispatcher.class.php"); require_once("src/php/com/cm/qa/ws/validator/Validator.interface.php"); require_once("src/php/com/cm/qa/ws/validator/ExpectedResultsValidator.class.php"); $r = RequestFactory::getInstance()->getFactory("GetMessageLog.xml"); print "<pre>"; while($request = $r->getRequest()) { try { $validator = new ExpectedResultsValidator(); $c = new CommandDispatcher($request->getURL()); $call = $request->getCall(); print "Executing $call \n"; $response = $c->dispatch($request); $expected = $request->getExpectedResults(); $report = $validator->validate($response, $expected); while ($myresults = $report->next()) { if($myresults->getState()) { print $myresults->getSearch() . " - PASS \n"; } else { print $myresults->getSearch() . " - FAIL \n"; } } } catch (FileNotFoundException$e) { } } Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-560241 Share on other sites More sharing options...
nadeemshafi9 Posted August 8, 2008 Share Posted August 8, 2008 i use PHP 4 OO cos most of our systems are legacey, there not compleetly oo like JAVA like you want yours i can see teh benifits of that but yeh that sounds best. there is alot more possible with PHP5, i think the MVC will be hard to impliment if you make it entirley, i can see things getting tricky if you use compleetly OOP Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-611650 Share on other sites More sharing options...
nadeemshafi9 Posted August 8, 2008 Share Posted August 8, 2008 i mean outputting HTML from classes is not a good it mixes teh MVC Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-611663 Share on other sites More sharing options...
nadeemshafi9 Posted August 8, 2008 Share Posted August 8, 2008 I started typing a response, but I ended up posting my thoughts on OOP here: http://nick.stinemates.org/wordpress/ This is about as procedural as my code gets (I dont expect it to make sense, its just an example): <?php require_once("src/php/com/cm/qa/ws/factory/RequestFactory.class.php"); require_once("src/php/com/cm/qa/ws/factory/FileNotFoundException.class.php"); require_once("src/php/com/cm/qa/ws/command/CommandDispatcher.class.php"); require_once("src/php/com/cm/qa/ws/validator/Validator.interface.php"); require_once("src/php/com/cm/qa/ws/validator/ExpectedResultsValidator.class.php"); $r = RequestFactory::getInstance()->getFactory("GetMessageLog.xml"); print "<pre>"; while($request = $r->getRequest()) { try { $validator = new ExpectedResultsValidator(); $c = new CommandDispatcher($request->getURL()); $call = $request->getCall(); print "Executing $call \n"; $response = $c->dispatch($request); $expected = $request->getExpectedResults(); $report = $validator->validate($response, $expected); while ($myresults = $report->next()) { if($myresults->getState()) { print $myresults->getSearch() . " - PASS \n"; } else { print $myresults->getSearch() . " - FAIL \n"; } } } catch (FileNotFoundException$e) { } } on your website you say "I find the lack of documentation of Python + ncurses somewhat exciting" i bet you also like to be dominated, sorry to break it to you buddy, its not actualy your code, just like english dosent belong to you its imposed on you because its made by somonee else before you. making things complex is like walking backwards why writwe in perl when you can write it in php not if they offered me a million £ i would never say "I find the lack of documentation of Python + ncurses somewhat exciting" i bet you `are best freind with ur boss and never come in l8 ? sorry i dont mean to judge u m8, its just touched a nerv for some reason you may be a great person. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-611694 Share on other sites More sharing options...
nadeemshafi9 Posted August 8, 2008 Share Posted August 8, 2008 you should be gratfull i have added +=1 to you google external links count to ur site by quoting you Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-611711 Share on other sites More sharing options...
JasonLewis Posted August 15, 2008 Share Posted August 15, 2008 I use OOP as much as possible now, and to PHP5 standards. But I went with partially OOP because, well... Yes I may use procedural, sometimes. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-617332 Share on other sites More sharing options...
keeB Posted September 2, 2008 Share Posted September 2, 2008 on your website you say "I find the lack of documentation of Python + ncurses somewhat exciting" Let's be fair. I also said I found it somewhat irritating. Of course, the engineer in me loves to explore and create something useful. Which I did. I wrote a Listbox implementation which you can see on the page. The irritating part is, that's about as far as I can go without reading related material in implementation. I can play around, sure, but really what I am left with is to actually read real world ncurses implementations, which is not trivial. The funny thing is, you and I believe in the same principles, they just seem to be lost a little in translation. I hate making things needlessly complex. I truly believe in creating simple, basic things. The process of leveraging these simple, basic things to create complexities which are easy to understand is almost artistic and (at least to me) beautiful. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-631724 Share on other sites More sharing options...
joquius Posted September 6, 2008 Share Posted September 6, 2008 I think the main virtue of PHP5 is that you can integrate the best of both worlds. I think it's better to have a parser object than a "text_functions.php" file. I also think it's pointless to start creating classes for every data type, and try to avoid languages like Ruby that take this to the extreme. But that's just my opinion; that's how I like to work. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-635117 Share on other sites More sharing options...
waynew Posted September 22, 2008 Share Posted September 22, 2008 Since I've started OO, I can't look at nor stand anything that is procedural. When the time comes for maintenance, you'll be happy. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-647571 Share on other sites More sharing options...
nadeemshafi9 Posted September 22, 2008 Share Posted September 22, 2008 Since I've started OO, I can't look at nor stand anything that is procedural. When the time comes for maintenance, you'll be happy. i think you have a solid point, classes can be modified easier than scattered procedural. but there are many legacy systems out there and lots of work 4 dem. Quote Link to comment https://forums.phpfreaks.com/topic/104791-object-oriented-in-php5/#findComment-647621 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.