|
Posted by FluffyCat on 12/17/52 11:56
On 23 Aug 2006 00:41:26 -0700, "Richard Levasseur"
<richardlev@gmail.com> wrote:
>I really like your site, since it provides clean, simple examples of
>common patterns.
>A few notes:
>Pass the code through highlight_string for some basic syntax
>highlighting, makes code a lot easier to read.
>And:
>I realized the one thing it is lacking though: an English description
>of the code you're about to read. The opening blurbs are very terse
>and don't explain the process and logic behind the pattern so much as
>give a text book definition of what it is. The code itself is very
>explanatory, but a providing a context can help immensely.
>
>Ex: Singleton: In the singleton pattern a class can distribute one
>instance of itself to other classes.
>
>Might be better worded as: <what it means> <what it is suppose to do>
><purpose in software designing> <common method of implementation>
><special cases to note>
>
>In the singleton pattern a class can control the instantiation of
>itself to the user. This is akin to having a global instance of an
>object, and is used when only a single instance of a class should
>exist.
>
>The common way of implementing this is storing a static, private
>instance of the class within the class and using a static class
>getInstance() method to fetch the stored instance.
>
>This is useful for:
>Database connections
>Configuration classes
>Controlling what instance a user gets
>When class instances should be shared regardless of context
>
>Feel free to copy/paste that and modify it as you wish.
Some great ideas there! You are certainly correct, I could well add a
bit more explanation to my examples. I generally start out with good
intentions, but I try to do an example all in one day when I can, with
the verbiage coming last. As a result by the time I do the verbiage
I'm not as enthusiastic as I was at the start. And - as is apparent
from my title for this thread - The Adapter Pattern instead of the
Bridge Pattern - perhaps getting a bit sloppy. It would probably a
good idea to go over all of my examples when I'm done the set, take a
fresh look, and add a bit more text.
I'd also like to add UML, but I haven't found a UML generator for PHP
that would create jpgs. And which is free.
Navigation:
[Reply to this message]
|