SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Addict
    Join Date
    Jan 2004
    Location
    New York
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Good PHP OOP software examples

    I was reading A Xmas Horror Story and always wondered myself why code in software is so badly written. I have not seen PHP software that follows good OOP practice.

    Do you guys have any good examples for us OOP learners to read?

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dig into the code for SimpleTest or WACT though that may not be the gentlest of introductions.

    Lurk on these forums and ask questions where you do not understand, some helpful soul will likely answer
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #3
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you making the assumption that if PHP code is not OO then it is badly written ?

    .. phpBB was a bad example , anyone who has any dealings with phpBB know that it is designed and built by committee and it shows ... phpBB1 was sloppy and insecure , phpBB2 is sloppy though despite the recent `issues` a bit more secure.

    phpMyAdmin has done pretty well for itself , it would drive McGruff to jumping off a cliff in dispair , or to write a version in pike , but it works , it works well & it mixes PHP/HTML everywhere , could you say that it is badly written ? well yes you could from the standpoint of many who fequent this forum.

    FUDforum , not as popular but extremely well written (it should be , it has good pedigree) does a much better content/logic seperation with pre-compiled templates etc , still not OO , so not well-written by the standards of some here.

    OScommerce , phpNuke etc are more bundles that do mighty well considering , though it would be fairer to point the 'sloppy' stick at them.

    serendipity again with a good pedigree , most would call well-written , however it too is a mix of OO , procedural code & php/HTML mixes.

    What I am trying to say is that OO !always= good code , at least not exclusively, surely the parameters that define what is 'well-written' should include whether it works as intended , do the authors know how it works , can they fix it when it breaks ? , not , is it OO , is it MVC , is it .. $etc.

    At the bottom of all of this is PHP's dynamically typed interpreted nature as opposed to strongly types compiled (be that to byte-code or otherwise) languages , but I have tried that argument here to no avail before so I wont even try

  4. #4
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to look at some of the frameworks like WACT, Mojavi, phpMVC, etc. and see if they have links to apps built using them.

    firepages does make a point that very few of the successful PHP apps are pure OOP. Hard to know whether that is because of the nature of scripting languages or if it is a comment of the current state of PHP development.

    Statements like "always wondered myself why code in software is so badly written" are purely subjective. If you thought about it you would realize that you just strongly criticized a lot of very good programmers code. You do not need to depreciate non-OOP methodologies to ask about OOP.

    Finally, I am fascinated by the statement "that follows good OOP practice." That seems to be the biggest moving target in programming. My impression is that they seem to come up with new ideas about what is "good OOP practice," and what is now bad, faster than most of us can integrate.

  5. #5
    SitePoint Evangelist
    Join Date
    May 2004
    Location
    Germany
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yesterday i read an article about plog in the german PHP Magazin

    plog is a OO blogging software using MVC. I don't know if it can be considered good software but perhaps one of the gurus here has already looked at it and can tell us about it.

    [edit]
    I tried looking at wact and other frameworks to learn something about oop, but for me the frameworks are to abstract to imagine how they can be used, so a "real" usage example might be better for oop beginners (like me )

  6. #6
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Atealtha
    I was reading A Xmas Horror Story and always wondered myself why code in software is so badly written. I have not seen PHP software that follows good OOP practice.

    Do you guys have any good examples for us OOP learners to read?
    Both Propel and Creole appear to be very well written http://phpdb.org/.

  7. #7
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I see, even if a piece of PHP doesn't do exactly what you want it to do, if it's well written like WACT, Mojavi, SimpleTest, etc, it does make it much easier to extend in a way that suits your requirements. Sloppy code only makes it harder to adapt, especially when new releases come out and you have to migrate / merge the changes you have orginally made into the new version.

  8. #8
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Atealtha if you want to learn advanced php I reccomend getting the php advanced visual quickstart guide book.
    Have a good day.

  9. #9
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are precious few. The Eclipse library is a good example of lean classes which do just one thing - but no unit tests. To qualify as well-written, code would have to include tests, I think.

  10. #10
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by McGruff
    There are precious few. The Eclipse library is a good example of lean classes which do just one thing - but no unit tests. To qualify as well-written, code would have to include tests, I think.
    I am sure Vincent was using tests for Eclipse. He published one of the first unit testing tools (still the simplest at only one script). It's a shame if he didn't ship them with the library.

    As for code quality, if you can understand the code and modify it to your needs without too many surprises then it is at least "good" code. That takes a bit of digging, so a few short hand rules would help. Look for unit tests. Code is a lot easier to change with tests in place. Look for tutorials as that usually shows concern for interfaces (here the user's first contact with the code). Look for good naming. The refactoring book (Martin Fowler) has a good list of "code smells" to watch out for. Also if the code has gone through a few versions the chances are it's had a number of internal improvements as well. Another factor is a willingness to explain the code on a first contact and to honestly admit shortcomings (e.g. Rephlux on SF) as this is how improvements are made.

    It's a craft. Look for a craftsman/craftswoman.

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  11. #11
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I assume why the more popular code is, well popular, is because its easier to use than others? PHPMyAdmin is very easy to use, heck I bet a lot of people who use PHPMyAdmin dont even know how to use mysql via command line.

    MS Windows is considered "bad code" yet its the most widely used software.

    Silly

  12. #12
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is telling that the only examples are a few OO libraries. If I hadn't developed a number of fairly large enterprise apps in PHP using pretty much pure OOP, I would be very doubtful after reading this thread. If it was Procedural programming you probably would not need to ask the question.

    I agree that Unit Testing is a powerful force to help you produce good code. Whichever way you program, you want to at least might want to read this:
    http://c2.com/cgi/wiki?ModularProgramming

    If you don't want to buy a book on Code Smells check here:
    http://c2.com/cgi/wiki?CodeSmell


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •