Re: Re: Re: [PHP] What's Your Favorite Design Pattern?

2012-02-10 Thread Jeremiah Dodds
On Wed, Feb 8, 2012 at 12:48 PM, Paul M Foster pa...@quillandmouse.com wrote:
 Um, yeah. It's very meta.

 (That's what I love about The C Programming Language. It's a little
 over half an inch thick in paperback, explains the whole language
 clearly and concisely, and has barely been revised since 1988. I'm not
 sure you could ask for more in a technical book.)

The C Programming Language is an exemplary language book -- it's
well-laid-out, and you can pick it up as a complete novice and end up
with enough of a grounding to get you going.

I don't share quite your level of distaste for Design Patterns, or the
GoF book. I found it pretty useful to read through, and was introduced
to some interesting ways of solving problems I had seen before. Minus
Singleton ;) I also found reading through the first part of the book
to be pretty enlightening. It's more than possible that a lot of the
benefit that I got from the book came from the experience-level I was
at when I read it -- I hadn't worked on any systems that I couldn't
fit entirely in my head at the time.

Most of the problems I've had with code that uses design patterns
have been with code where the authors used the patterns in a
prescriptive manner -- like they were looking for ways to fit their
problem into a neat architecture that they didn't need and didn't
understand. I don't think they were (or are) meant to be used in that
manner, they're supposed to be part of a shared language for
high-level patterns used to solve particular families of architecture
issues when they're needed. Letting the existing names and
implementations and suggested use-cases of design patterns dictate
your codebase is a recipe for disaster.

I also happen to agree with the idea that the existence of design
patterns can be a language-deficiency smell, but hey, we don't always
get to work with the languages we prefer to work with.

Anyhow, that's my two cents.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: Re: [PHP] What's Your Favorite Design Pattern?

2012-02-08 Thread Tim Streater
On 07 Feb 2012 at 22:31, Paul M Foster pa...@quillandmouse.com wrote: 

 Design Patterns are Way Nifty Kewl patterns of code which are supposed
 to facilitate certain types of operations. (Was that sarcasm you
 detected? Yes it was.)

 For example, the Singleton pattern. Let's say you had a configuration
 class that held the configuration values for your application, and you
 wanted to make sure there was only one object of that class
 instantiated, no matter how many times it was called in your code. You'd
 arrange the code and call the class in a certain way to ensure that only
 one object of that class resulted. To make your configuration class a
 singleton, you'd probably make the class have a *private* constructor
 (so no outside routine could call it), and then provide a method called
 get_instance() which tested for the existence of an object of that
 class. If such an instance was found, someone calling
 configuration::get_instance() would simply get the existing object
 returned to them. Otherwise, configuration::get_instance() would
 instantiate the class and then return the new object to the caller.

 As you can see, that's a peculiar way of setting up your code for a
 specific purpose. Other design patterns do other things and dictate
 setting up things in other ways.

 The definitive work on this (and where it first gained the most
 publicity) is a book called Design Patterns by four authors (Gamma,
 Helm, Johnson and Vlissides). It essentially contains a chapter about
 each (known at the time) design pattern and some pseudocode about how it
 might be constructed. I imagine the authors looked at a lot of code and
 discovered that programmers were coming up with code that, in each case
 was remarkably similar for solving certain types of programming
 problems. So they codified what that found and wrote a book about it.

 I have the book on my shelf, and it's decent technology, but you could
 spend your whole career and never use any of it, and get along just
 fine.

Mmmm. Well, at this point I feel underwhelmed - but its entirely possible that 
I'm missing something profound [1]. After looking at some of the reviews of the 
book you mention on Amazon, I might be inclined to get a simpler intro.

[1] In June 1982 (or was it '83?) I visited PARC with a small group from SLAC. 
We saw the Star or whatever it was, with bit-mapped display and mouse pointer. 
Whoosh !! (Well, to be fair, we'd gone along to look into XNS).

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: Re: [PHP] What's Your Favorite Design Pattern?

2012-02-08 Thread Paul M Foster
On Wed, Feb 08, 2012 at 02:25:00PM +, Tim Streater wrote:


[snip]

 
 Mmmm. Well, at this point I feel underwhelmed - but its entirely
 possible that I'm missing something profound [1]. 


Not really. 

 After looking at some of the reviews of the book you mention on
 Amazon, I might be inclined to get a simpler intro.

Um, yeah. It's very meta. 

(That's what I love about The C Programming Language. It's a little
over half an inch thick in paperback, explains the whole language
clearly and concisely, and has barely been revised since 1988. I'm not
sure you could ask for more in a technical book.)

 
 [1] In June 1982 (or was it '83?) I visited PARC with a small group
 from SLAC. We saw the Star or whatever it was, with bit-mapped display
 and mouse pointer. Whoosh !! (Well, to be fair, we'd gone along to
 look into XNS).
 

I remember working for Xerox (copy center employee) around that time,
and seeing all kinds of talk in the company materials about *Ethernet*.
They explained the basic protocol and compared it to token ring, and I
just thought, Hmm, yes, that seems like a pretty clever way to go about
networking.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php