Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Professional PHP Design Patterns
|
BOOK: Professional PHP Design Patterns
This is the forum to discuss the Wrox book Professional PHP Design Patterns by Aaron Saray ISBN: 978-0-470-49670-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional PHP Design Patterns 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 January 8th, 2010, 09:26 PM
Registered User
 
Join Date: Jun 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Qns regarding Builder Pattern example

With reference to productBuilder class in page 35, i wonder what does the statement
Code:
$this->_xml = $configs;
do?

or should the build() method be

Code:
public function build(){
 $this->_product->setSize($this->_xml['size']);
 $this->_product->setType($this->_xml['type']);
 $this->_product->setColor($this->_xml['color']);
}
instead?
 
Old January 10th, 2010, 01:59 PM
Wrox Author
 
Join Date: Sep 2009
Posts: 15
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hey - great catch. The example should be the following code:

PHP Code:
class productBuilder
{
    protected 
$_product NULL;
    protected 
$_configs = array();

    public function 
__construct($configs)
    {
        
$this->_product = new product();
        
$this->_configs $configs;
    }

    public function 
build()
    {
        
$this->_product->setSize($this->_configs['size']);
        
$this->_product->setType($this->_configs['type']);
        
$this->_product->setColor($this->_configs['color']);
    }

    public function 
getProduct()
    {
        return 
$this->_product;
    }

Sorry for any confusion. Thanks so much!
__________________
-aaron
--
aaronsaray.com || <-- yeah... try it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Platform Builder and C# Bill_Thompson C# 2005 0 January 21st, 2009 08:26 PM
course builder youyou_hym Dreamweaver (all versions) 1 May 28th, 2008 03:09 AM
Command Builder BSkelding ASP.NET 1.0 and 1.1 Professional 3 April 18th, 2005 12:03 PM
DirectoryInfo.GetFiles(pattern): search pattern fo arif_1947 VS.NET 2002/2003 1 October 19th, 2004 11:59 PM





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