Jump to content

new references


mannyee

Recommended Posts

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

 

 

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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?

Link to comment
Share on other sites

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:

 

 

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)?

Link to comment
Share on other sites

  • 3 weeks later...

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....?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.