mannyee Posted May 18, 2010 Share Posted May 18, 2010 hi guys!! after few projects in procedural php, i'm now firing off with OOP. i have the OOP concepts and followed few OOP design tutorials, including one mentioned in the 'sticky'. well, but while writing my own code, time and again, i have difficulty organizing methods, and such..... i'm working on a dashboard project...(a mini project that must be completed in a weeK).....i could finish that off in about 3 days in procedural way....but with OOP i'm heading nowhere. at this point i desperately need some OOP project reference with proper commenting and/or any reference tutorials/guides. thanks in advance!! -mannyee Quote Link to comment https://forums.phpfreaks.com/topic/202108-new-references/ Share on other sites More sharing options...
CodeMaster Posted May 18, 2010 Share Posted May 18, 2010 Personally I would recommend to learn OOP by learning Java or something. These languages are much more into OOP than PHP is. I did not understand OOP in PHP, before I learned Java myself. If you want to apply OOP you must know why OOP is so useful. PHP is just a wannabee OOP language. But it is really useful when building large systems. With OOP you can easily overwrite a class method, without replacing the whole class. So if it is supposed to be modulair system, than I would recommend it. If just a small website, no need to use classes. I will post you a copy of a class I made for overwriting a default class in PHP: mysqli. You will see why it is useful. I can overwrite the query method in mysqli, but the other methods remain the same. class mysqli_advanced extends mysqli { public function query($query) { if (!$result = parent::query($query)) { throw new mysqlExp(); } else { return $result; } } } In PHP I would further recommend using classes for building your own exceptions. Which can be useful for logging errors or something. http://www.brandonsavage.net/exceptional-php-extending-the-base-exception-class/ Quote Link to comment https://forums.phpfreaks.com/topic/202108-new-references/#findComment-1059886 Share on other sites More sharing options...
ignace Posted May 18, 2010 Share Posted May 18, 2010 If just a small website, no need to use classes. OOP gives you no gain if the project is to small or the deadline to short. i have difficulty organizing methods Maybe CRC cards is what you need. http://en.wikipedia.org/wiki/Class-responsibility-collaboration_card at this point i desperately need some OOP project reference with proper commenting and/or any reference tutorials/guides. Writing effective OOP is not taught by going over someone else's code, for example: class SearchController extends Zend_Controller_Action { public function indexAction() { $this->view->found = $this->searchService->findResultFor( $this->searchService->select()->where('name LIKE ?', '%' . $this->getRequest()->query . '%')); } } Teaches you nothing if you don't understand the motivation. First you must have a good understanding of the SOLID principles (http://en.wikipedia.org/wiki/Solid_%28object-oriented_design%29) and OOP patterns (http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29#Classification_and_list) and OOP anti-patterns (http://en.wikipedia.org/wiki/Anti-pattern) and good practices. OOP is not taught in merely days or weeks. Quote Link to comment https://forums.phpfreaks.com/topic/202108-new-references/#findComment-1059952 Share on other sites More sharing options...
mannyee Posted May 19, 2010 Author Share Posted May 19, 2010 thanks for your suggestion guys.... @ignace: Writing effective OOP is not taught by going over someone else's code well....i do agree that....i have the understanding of the basic OOP concepts and i've to submit this mini-project for evaluation for my OOP class. someone suggested me that i could take a good reference to start my own. what alternatives are there? Quote Link to comment https://forums.phpfreaks.com/topic/202108-new-references/#findComment-1060346 Share on other sites More sharing options...
ignace Posted May 19, 2010 Share Posted May 19, 2010 i have the understanding of the basic OOP concepts If by that you mean I know how to write a class, then no you don't. The concepts revolve around inheritance, abstraction, encapsulation, and polymorphism. Do you know what polymorphism means? And what encapsulation means? And I already gave you resources: http://en.wikipedia.org/wiki/Solid_%28object-oriented_design%29 SOLID OOP principles http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29#Classification_and_list OOP patterns someone suggested me that i could take a good reference to start my own. What kind of reference? OOP? OOA&D (as you are creating a project)? Quote Link to comment https://forums.phpfreaks.com/topic/202108-new-references/#findComment-1060422 Share on other sites More sharing options...
mannyee Posted June 5, 2010 Author Share Posted June 5, 2010 within these few days....i spent time studying oop patterns and ofcourse the links you provided. but the further i study, the more confused iam. if you are other guys don't mind....can i post the summary of what my application should do so that you guys can give me hints....? Quote Link to comment https://forums.phpfreaks.com/topic/202108-new-references/#findComment-1068118 Share on other sites More sharing options...
ignace Posted June 5, 2010 Share Posted June 5, 2010 if you are other guys don't mind....can i post the summary of what my application should do so that you guys can give me hints....? Don't ask, do. Facta, non verba. Quote Link to comment https://forums.phpfreaks.com/topic/202108-new-references/#findComment-1068121 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.