SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 42
  1. #1
    SitePoint Guru
    Join Date
    Feb 2002
    Posts
    625
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Review: Guide to PHP Patterns

    Although I had sworn not to by any language specific books anymore (cause 4 out of 5 times it was wasted money), I couldn't resist to see what someone has made out of Patterns in relation to PHP.

    So I went over to PHP Architect and ordered the PDF along with the hardcover (after all, who doesn't prefer to read a book in bed).

    I received the hardcover pretty quick, I think it was 2 weeks (note I live in Belgium, Europe). No complaints here.
    Rather then try to write a professional review I am just going to share my thoughts.

    Alas for me there wasn't much in the book that was new to me, but I sure think that the explanation of the DB related patterns beats the *** out of the PoEAA explanation. Well done.

    Also for many people the book will be of great help when they are new to patterns in general but have a solid knowledge of PHP and it's OOP capabilities. Although you should still have a copy of Design Patterns.

    The book is well structured, although there are some typo's. Personally I am not too fond having to skip through the testing code (because most of it is [to me] just so straight forward), but on the other hand it should educate a lot of people and at the same time teach them how to test their code.

    I think what's really a pitty is that the author failed to integrate the general Design Principles along with the patterns, seeing how they perfectly fit in, on the other hand I guess the intention of the book is more to show how to implement patterns in PHP.

    Put simply, if you have good knowledge of PHP and OOP (inheritance, composition and polymorphism is not something that scares you), you maybe even have heard about Design Principles, yet have no idea how to implement a DataMapper in PHP, then this book is for you.(get Design Patterns alongside it though, especially if the only language you know is PHP, this is where GPDP will shine the most I think)

    I believe the price should (if possible) never be a consideration (how can you judge the value of a book by it's price?), but for those who study or are waiting for clients to pay, or just generally on a tight budget (you get the picture), the book is even priced cheap! So there you go.

    Summary: Most likely one of the most usefull books ever written for the intermediate to advanced PHP developers.

    As a personal sidenote: What totally struck me like lightning is that the Author promotes ADODB. I have absolutely NO IDEA why he would promote something that's FULL of bad smells and ugly code with GLOBALS everywhere and the main class consisting of 3800+ lines of code and to put simple is a perfect example of bloatware (which does NOT mean it doesn't work as expected). I truly don't understand that. But that's another topic really...
    Last edited by datune; Oct 28, 2005 at 16:11.

  2. #2
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are learning patterns (like me) and have been seduced by all the good looking looks aimed at Java developers this book fills in the gaps, it:

    - adds real world applications that WE (PHP web developers) can relate too
    - gives you the exact php4 and PHP5 syntax
    - makes Unit testing look so simple, you know it has to make sense

    Its aimed at a certain niche and fills it admirably.

    I am reading this alongside "Head First Design Patterns", that and trying to follow the threads on this forum. I am having some mad OO dreams I can tell you.

    Best book I've read since Trachtenbergs "Upgrading to PHP5", which sold me on so many of new issues.

  3. #3
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I ordered this book as well - arrived the other day, and I havn't really done much more than flick through it yet. Looks good though!

  4. #4
    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)
    Quote Originally Posted by datune
    Summary: Most likely one of the most usefull books ever written for the intermediate to advanced PHP developers.
    Thank you very much for your kind words. I hoped to target just the audience you mention, intermediate to advanced PHP developers with OOP familiarity and a desire to learn design patterns in a familiar language. I also wanted to emphasize the testing side of development and give people good solid example of TDD in PHP. I also wanted to give equal time to PHP4 and PHP5 because I don't see the "tipping point" for PHP5 adoption yet, and it seems like every OOP PHP practitioner only wants to write PHP5 example, when in reality the larger usage base is likely to be PHP4 for some time yet.

    I hope these combinations of factors give the book a strong and useful niche and give the book lasting utility on many PHP developersí bookshelves.


    Quote Originally Posted by datune
    As a personal sidenote: What totally struck me like lightning is that the Author promotes ADODB. I have absolutely NO IDEA why he would promote something that's FULL of bad smells and ugly code with GLOBALS everywhere and the main class consisting of 3800+ lines of code and to put simple is a perfect example of bloatware (which does NOT mean it doesn't work as expected). I truly don't understand that. But that's another topic really...
    ADOdb was in the right place at the right time for me.

    When I first started developing in PHP, I saw the need for a db abstraction layer. I was working with Sybase at home (mainly because I had just moved from ASP/MSSQL to PHP, and the Sybase stored procedures we identical to MSSQL6.5 so it was one less learning hurdle to overcome). At first I tried some random db abstraction library I downloaded from the Zend. It had a MySQL driver (as expected) and I was easily able to create a Sybase driver for it by porting the functions with global search and replace. It worked, but unfortunately it was probably a community of two--me and the original author.

    When I began to write articles, I looked for a more popular solution, and settled on PEAR::DB. This was what I used for my first Three Tier Application tutorials. I wrote the article using Sybase and assuming the MySQL driver would work fine for people to follow my examples. Unfortunately, this did not end up being the case and the constructs I was using for looping over a result set failed to work when using MySQL. I was able to easily figure out how to correct it, but I felt embarrassed and it left a bad taste in my mouth, after all what good was a database abstraction layer which fails to abstract

    (NOTE: Though I have not used it recently, I am sure the problems I experience with PEAR::DB are long since put to rest, and people should definitely not use my ancient experience as a basis for a current evaluation of database abstraction layers)

    I then tried out ADOdb. It worked, had a consistent API for MySQL, Sybase and Oracle (which I used at work, and was starting to push for PHP usage there). As a bonus, it was higher performance based on the benchmarks available and based on my trials.

    ADOdb was always one step ahead of my Oracle needs at work. When I needed LOBs, there was already an established API there for handling it. When I wanted to use ref cursors returned from PL/SQL functions, again, ADOdb was ahead of my needs and already had an API in place.

    So why do I still use ADOdb? It has been a work horse for me, high performance and always has met my requirements. I guess you could just say there it too much inertia for me to move out of my comfort zone :)

    For the book I had a choice to make.
    a) write a db abstraction library as a part of the book
    b) use some other db abstraction library that I did not know and have to spend the time learning it
    c) use ADOdb that I know

    In the end, ADOdb provides and adequate API for the examples I wanted to show, and is a publicly documented, reasonable popular project. It was just a choice I had to make, and hopefully it worked out well in the end for the book.

    Regards,
    Jason
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  5. #5
    SitePoint Guru
    Join Date
    Feb 2002
    Posts
    625
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and hopefully it worked out well in the end for the book
    I am very sorry if I gave the impression that the choice of DB abstraction influenced the quality of the book. (which of course it doesn't!).

    Thank you very much for this thorough explanation

  6. #6
    SitePoint Enthusiast Stryderjzw's Avatar
    Join Date
    May 2002
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi! Nice review. I think I'm going to get this book because it has that TDD focus.

    One question though, for sweatje, amazon.ca lists the book as 28 dollars, and php|arch has it for 42 dollars... Any reason for that? (I'm guessing just because Amazon can so they attract you to buy from them)... Should I buy from php|arch or Amazon?

  7. #7
    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)
    I think you can get both the PDF and hardcopy version from phparch, only the hardcopy from Amazon. Of course since I got ten copies to begin with I have not done a lot of research into where to purchase it
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  8. #8
    Non-Member melancholic's Avatar
    Join Date
    Nov 2004
    Location
    Australia
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there,

    I bought it from php|arch, downloaded the pdf and straight away, the path to "infection" has been lit for me.

    I am particularly appreciative of JES's goals to drive the principles of TDD (and simpletest) with his examples as up to this point, it's been nothing more but a scary acronymn or buzz word to some (myself especially).

    A good reference book for those who have a grasped the concept of OOP and want to learn about design pattern implementation in PHP.

    Regards,

    'cholic

  9. #9
    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)
    Quote Originally Posted by melancholic
    the path to "infection" has been lit for me.
    No words could make me happier I hope the book continues to be a valuable reference for you.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  10. #10
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I keep my copy handy beside me

    One thing I noticed is the spine is printed upside-down. I ordered another book published by PHP|A as well and the same thing... haha... wonder if they are aware they've printed their books with upside-down spines.

  11. #11
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dreamscape
    I keep my copy handy beside me

    One thing I noticed is the spine is printed upside-down. I ordered another book published by PHP|A as well and the same thing... haha... wonder if they are aware they've printed their books with upside-down spines.
    Define "upside down"... they look okay to me (plus, you can tell our books apart right away :P)

  12. #12
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mtabini
    Define "upside down"... they look okay to me (plus, you can tell our books apart right away :P)
    Compare it to other books [or CDs, DVDs, or anything else with a spine]. I think you will find the spine [on most] is printed so that it is readable when the book is standing up or laying flat on its back [in a stack, since you can read the cover if nothing is on it]. Now look at the spine on PHP|A's books. They are printed opposite of the way it is typically done (I would maybe say always done since PHP|A's books are the first one's I have encountered that are printed this way), hence upside-down. Also lay the book flat on it's back, and the print on the spine is literally upside-down because of this.

  13. #13
    SitePoint Zealot Quadzoola's Avatar
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but I sure think that the explanation of the DB related patterns beats the *** out of the PoEAA explanation.
    I'm actually just polishing off PoEAA and have found it quite enlightening in many aspects including the section on DB related patterns. Could you elaborate a bit more on why sweatje's explanation is that much better. To be honest GPDP is on my wishlist but I just may bump it up a notch or two.
    Jeff Busby

  14. #14
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's also a lot of material about unit testing in sweatje's book and of course all the examples are in php.

  15. #15
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And not only are all examples in PHP, but in most cases he gives us an example in PHP4 and in PHP5. Other recent PHP pattern oriented books I've looked through only give PHP5 examples.

  16. #16
    SitePoint Evangelist
    Join Date
    Jun 2003
    Location
    Melbourne, Australia
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dreamscape
    One thing I noticed is the spine is printed upside-down.
    More important (and discouraging) is uneven guillotining of pages and quite a few typos and errant linebreaks. I really would have expected better editing of the final copy.

    Does not take away from the content, which is great.
    Zealotry is contingent upon 100 posts and addiction 200?

  17. #17
    SitePoint Guru
    Join Date
    Feb 2002
    Posts
    625
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Quadzoola
    I'm actually just polishing off PoEAA and have found it quite enlightening in many aspects including the section on DB related patterns. Could you elaborate a bit more on why sweatje's explanation is that much better. To be honest GPDP is on my wishlist but I just may bump it up a notch or two.
    I ment in terms of ease of understanding. The explanation given by Jason is a hands on example which will not need to be read twice to fully appreciate the DataMapper pattern.

    Instead of an "Ok... I hear what you are saying...*cough*..." experience once the chapter was finished (PoEAA), reading Jason's was more like "Oh ok, so that's how (one possible) implementation of a DataMapper in PHP looks like. *rub hands*...excellent...". Know what I mean?

    As to the spine issues and the typos, well they don't bother me at all, and considering the cheap price I can perfectly live with it. Let's keep in mind where the book is coming from in the first place. Frankly, the folks over at phpA deserve a pat on the back

  18. #18
    SitePoint Evangelist tetsuo shima's Avatar
    Join Date
    Oct 2005
    Location
    Switzerland
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ordered it, got it, loved it. But darn... I didn't know at all that it had been written by a SPF member... Probably missed it if it was written somewhere in the book.

    Great stuff.


  19. #19
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Worcester
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Received my copy yesterday and couldn't put it down! It's very easy to read and the use of tests to show implemenation and use is really handy. Definitely worth having on the bookshelf.

    If anything, the book is named wrong; it should be "php|architect's Guide to PHP Design Patterns and Testing".

  20. #20
    SitePoint Zealot Quadzoola's Avatar
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by datune
    Instead of an "Ok... I hear what you are saying...*cough*..." experience once the chapter was finished (PoEAA), reading Jason's was more like "Oh ok, so that's how (one possible) implementation of a DataMapper in PHP looks like. *rub hands*...excellent...". Know what I mean?
    Ah.

    /hears pin dropping
    Jeff Busby

  21. #21
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dreamscape
    One thing I noticed is the spine is printed upside-down. I ordered another book published by PHP|A as well and the same thing... haha... wonder if they are aware they've printed their books with upside-down spines.
    This might be off topic (ok it is), but when I browse books in London, I tilt my head to the right to read the spines. In France I noticed I have to tilt my head to the left to read the spines. Maybe its a continental thing? Like they drive on the wrong side too?

  22. #22
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also bought the book a short while ago and read through it - it's awesome. It exactly fulfilled the reason why I bought it in the first place: Since I know my way pretty much around design patterns I bought it almost only because it would take the TDD approach (testing first). I simply wanted to see a real life example of TDD, because I cannot make myself get the around to the habit of testing before coding and the book just fulfilled my expectations.

    Well done Jason.

    I was just of the opinion that a few coding approaches could have been made otherwise like the add() method on page 42 should IMO not return a new ValueObject. I think it would be better if it simply updated the $amount:

    PHP Code:
    public function add($dollar) {
         
    $tmp = new Dollar($this->amount $dollar->getAmount());
         
    $this->amount=$tmp->getAmount();

    ..but that's just me. What do you think Jason?

  23. #23
    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)
    Quote Originally Posted by DarkAngelBGE
    Also bought the book a short while ago and read through it - it's awesome. It exactly fulfilled the reason why I bought it in the first place: Since I know my way pretty much around design patterns I bought it almost only because it would take the TDD approach (testing first). I simply wanted to see a real life example of TDD, because I cannot make myself get the around to the habit of testing before coding and the book just fulfilled my expectations.

    Well done Jason.
    Thanks, I appreciate the feedback!

    Quote Originally Posted by DarkAngelBGE
    I was just of the opinion that a few coding approaches could have been made otherwise like the add() method on page 42 should IMO not return a new ValueObject. I think it would be better if it simply updated the $amount:

    PHP Code:
    public function add($dollar) {
         
    $tmp = new Dollar($this->amount $dollar->getAmount());
         
    $this->amount=$tmp->getAmount();

    ..but that's just me. What do you think Jason?
    I think it would no longer be a value object at that point Consider the Monopoly example where the $game object is holding a reference to a $go_amount Dollar object. The player draws a card which is supposed to give him the $go_amount + 50 just once.

    PHP Code:
    $player->balance->add($game->go_amount->add(new Dollar(50))); 
    and oops now everyone is going to get $250 every time they pass go.

    Basically what you have lost with your proposed implementation is the immutable aspect of the value object.

    HTH
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  24. #24
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Umm...

    I don't have the book, but maybe someone could post the script as per what is being discussed, so I can understand a bit more?

    Domain Driven Design talks about immutable objects, etc so I suppose I might take a look at the related chapter sometime later...

    Thanks, I appreciate the feedback!
    Of course you do

  25. #25
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
     $player->balance->add($game->go_amount->add(new Dollar(50))); 
    Jason, in that example, it's not the $game object that is the problem, but the $player object, in the way that the wrong amount is returned? That's a guess I suppose, so am I close?


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
  •