Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1
This is the forum to discuss the Wrox book Professional PHP5 by Ed Lecky-Thompson, Heow Eide-Goodman, Steven D. Nowicki, Alec Cove; ISBN: 9780764572821
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 25th, 2005, 03:28 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Working Code for Chapter 4

I need help for the code on Chapter 4 about the Observer Pattern!
Not so many rows but this won't work. Maybe I'm not so an advanced Oop developer with Php5, but I had some problems even using the downloaded code from Wrox 'till now. The past Chapter 3 contact manager application simply won't work anyway, even with the wrox code. I had past Oop experiences with Java and Actionscript2. So I hope the mistakes are in the sintax and not in the logic of the application.
Please Wrox (and Authors): give more support and publish correct code! Books are intended to learn not to drive crazy! Other than that this is really an amazing book for the advanced developer.
 
Old December 26th, 2005, 06:44 AM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Chapter 4 Observer Pattern (useful also for decorator) code:
After 15 minutes I fixed the code this way (changes in bold).

<?php
//OBSERVER PATTERN
//abstract_widget.php
//
interface Observer {
    public function update(Observable $subject);
}
//error in this class
abstract class Widget implements Observer {
    protected $internalData = array();

    abstract public function draw();

    public function update(Observable $subject) {
        $this->internalData = $subject->getData();
    }
}
....
?>

since abstract class Widget implements the Observer interface, its update method should accept the same parameters.
I hope I'll find a fix even for the chapter 3 application...




Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 1 - Working Widget Code php4ever BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 5 September 5th, 2013 02:16 PM
Chapter 4 - Two Views, not working for me... bigtalk BOOK: Beginning Ruby on Rails 1 January 3rd, 2008 07:30 AM
Chapter 6: store not working Giorgio84 BOOK: Beginning Ruby on Rails 2 June 17th, 2007 11:17 PM
Chapter 1: Greeting Not Working Joe3000 BOOK: Beginning Ruby on Rails 2 June 14th, 2007 10:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.