From 7d91e9cd07d982635cfe2e39e6e3e7a41ee0fc1c Mon Sep 17 00:00:00 2001 From: Florian Wolters Date: Wed, 13 Mar 2013 15:52:19 +0100 Subject: [PATCH 1/2] Removed trailing whitespaces. --- pages/Design-Patterns.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pages/Design-Patterns.md b/pages/Design-Patterns.md index 3f510ac..041928a 100644 --- a/pages/Design-Patterns.md +++ b/pages/Design-Patterns.md @@ -64,11 +64,11 @@ yourself a lot of trouble down the road by using factories. ## Singleton -When designing web applications, it often makes sense conceptually and architecturally to allow access to one and +When designing web applications, it often makes sense conceptually and architecturally to allow access to one and only one instance of a particular class. The singleton pattern enables us to do this. {% highlight php %} - Date: Wed, 13 Mar 2013 16:21:22 +0100 Subject: [PATCH 2/2] Enhanced the example for the Singleton design pattern. - Moved static variable into the static creation method getInstance. - Replaced "new self();" with "new static" (late static binding to allow subclassing). - Changed visibility of __construct to protected. - Added the two private methods __clone and __wakeup. - Added DocBlock comments. - Updated description and enhanced with links to the PHP manual. --- pages/Design-Patterns.md | 66 ++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/pages/Design-Patterns.md b/pages/Design-Patterns.md index 041928a..75c14d3 100644 --- a/pages/Design-Patterns.md +++ b/pages/Design-Patterns.md @@ -71,30 +71,72 @@ only one instance of a particular class. The singleton pattern enables us to do