POV-Ray : Newsgroups : povray.off-topic : Design patterns Server Time
7 Sep 2024 09:21:26 EDT (-0400)
  Design patterns (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Darren New
Subject: Design patterns
Date: 4 Jul 2008 22:19:26
Message: <486eda2e$1@news.povray.org>
Is it me, or is the GoF book "Design Patterns" really over-hyped? Every 
time I hear it mentioned, it's along the lines of "wow, isn't it great 
they teach you all these tricks?"  When really, all they're doing is 
naming stuff that everyone does, most of which predates OO programming 
to start with.

I mean, really.  <Warp> I don't get it. </Warp>

Factory Method - you don't know what class to instantiate, so put the 
class in a variable. A kludge only when a language isn't OO enough to 
have objects that represent classes.

Abstract Factory - you don't know which collection of classes to 
instantiate, so put the collection of classes in a variable.

Singleton - you only want one, so use a global variable.

Adapter - you have two incompatible libraries, so write routines that 
translates between the two.

Bridge - abstract class, opaque pointer.

Proxy - this word has meant the same thing since Latin-speaking romans 
invented it.

Iterator - In any actually fully-OO language, this is the only way to 
access the elements of an aggregate object sequentially, let alone with 
or without exposing the underlying representation.

Memento - for languages too lame to be able to reflect.

Mediator - MVC, around 30 years ago, and also pretty obvious given the 
problem it's supposed to solve.

Observer - Part of MVC, also around 30 years ago, and a pretty obvious 
way of structuring programs.

Template method - the normal way of using virtual methods.

Chain of responsibility - multiple functions might handle this, so call 
them one at a time until one handles it, duh.

Facade - You didn't finish writing the code to be useful, so I'll finish 
it and call it a facade.


Seriously, how are you supposed to use this book? Are you supposed to 
not know that you can have a method in a superclass that does different 
things by calling methods implemented in its subclasses? Did you not 
know that if you want to enforce only having one of something, you can 
put it in a global variable and use that? Or is somehow giving a special 
name to "global variable" somehow make it easier to communicate with 
someone? How does it help to give special names to different types of 
compatibility layers, depending on whether the layers involve single 
classes, single methods, or collections of classes?

-- 
Darren New / San Diego, CA, USA (PST)
  Helpful housekeeping hints:
   Check your feather pillows for holes
    before putting them in the washing machine.

-- 
Darren New / San Diego, CA, USA (PST)
  Helpful housekeeping hints:
   Check your feather pillows for holes
    before putting them in the washing machine.


Post a reply to this message

From: Gail Shaw
Subject: Re: Design patterns
Date: 5 Jul 2008 03:17:00
Message: <486f1fec@news.povray.org>
"Darren New" <dne### [at] sanrrcom> wrote in message
news:486eda2e$1@news.povray.org...
> Is it me, or is the GoF book "Design Patterns" really over-hyped? Every
> time I hear it mentioned, it's along the lines of "wow, isn't it great
> they teach you all these tricks?"  When really, all they're doing is
> naming stuff that everyone does, most of which predates OO programming
> to start with.

I haven't read it, though I have read some other books on patterns, so this
is just my take.

Firstly, having standard names for things makes communication easier. System
designer can just say "I want you to use a Abstract Factory" and in theory
the developer nows exactly what to do.
I've seen patterns described as 'documented good practices'. They're
probably more useful for the average developer than for the gurus because
they show something that does work (if used in the right circumstances)


Post a reply to this message

From: Warp
Subject: Re: Design patterns
Date: 5 Jul 2008 04:40:34
Message: <486f3381@news.povray.org>
There really *are* design patterns which might sound obvious to you
and me, but are not all that obvious to many programmers who are starting
to dig into OOP.

  One example I like (and which name I rather ironically cannot remember
now) is the design pattern which you can use to create primitives and
unions of primitives, so that the union itself is a primitive (thus
allowing a union to contain other unions, containing other unions,
thus forming a whole hierarchy of primitives).

  For example, let's assume that you have three primitives: Line, rectangle
and circle, and you also want to be able to make compound objects containing
any amount of those (so that you can, for example, transform all of them
as if they were one single primitive). Of course it would be nice if such
a compound object could contain other compound objects as well. Thus this
compound object should be a primitive itself.

  Hence the inheritance hierarchy would be something like this:

Primitive
  '--> Line
  '--> Rectangle
  '--> Circle
  '--> Union
         '--Contains: List of <Primitive>

  In other words, if that was drawn as an UML diagram, there would be
a "contains" arrow from 'Union' back to 'Primitive', making the hierarchy
recursive.

  This is a simple idea and might be obvious to some, but it certainly
might not obvious to the new OO programmer.

  The book Design Patterns is full of tidbits like this, making it
potentially quite useful to someone.

-- 
                                                          - Warp


Post a reply to this message

From: Orchid XP v8
Subject: Re: Design patterns
Date: 5 Jul 2008 05:03:51
Message: <486f38f7$1@news.povray.org>
Warp wrote:
>   There really *are* design patterns which might sound obvious to you
> and me, but are not all that obvious to many programmers who are starting
> to dig into OOP.
> 
>   One example I like (and which name I rather ironically cannot remember
> now) is the design pattern which you can use to create primitives and
> unions of primitives, so that the union itself is a primitive (thus
> allowing a union to contain other unions, containing other unions,
> thus forming a whole hierarchy of primitives).

It's called Container or Composite or something like that. (Also related 
to the Decorator pattern - although that does the same thing for a 
different reason.)

>   This is a simple idea and might be obvious to some, but it certainly
> might not obvious to the new OO programmer.

Many good ideas seem obvious *after* somebody told you. ;-)

For example, (A*B)^2 - 4*(A+B) = (A-B)^2. Obvious once you know, but 
DAMN... I've have never thought of it!

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Gail Shaw
Subject: Re: Design patterns
Date: 5 Jul 2008 05:07:00
Message: <486f39b4@news.povray.org>
"Orchid XP v8" <voi### [at] devnull> wrote in message
news:486f38f7$1@news.povray.org...
>
> Many good ideas seem obvious *after* somebody told you. ;-)

Which is as good a reason as any to make the patterns known. So we don't get
novice programmers who just don't know the tried and trusted ways
reinventing the wheel, usually badly.


Post a reply to this message

From: Paul Fuller
Subject: Re: Design patterns
Date: 5 Jul 2008 07:56:23
Message: <486f6167$1@news.povray.org>
Orchid XP v8 wrote:
> For example, (A*B)^2 - 4*(A+B) = (A-B)^2. Obvious once you know, but 
> DAMN... I've have never thought of it!
> 
Well that is true for some values of A an B - But probably not as many 
as you think.

Whereas (A+B)^2 - 4*(A+B) = (A-B)^2 is true a few more cases.

Unless you have redefined the * and + operators :)


Post a reply to this message

From: Orchid XP v8
Subject: Re: Design patterns
Date: 5 Jul 2008 08:28:48
Message: <486f6900$1@news.povray.org>
>> For example, (A*B)^2 - 4*(A+B) = (A-B)^2. Obvious once you know, but 
>> DAMN... I've have never thought of it!
>>
> Well that is true for some values of A an B - But probably not as many 
> as you think.
> 
> Whereas (A+B)^2 - 4*(A+B) = (A-B)^2 is true a few more cases.
> 
> Unless you have redefined the * and + operators :)

NAAAAARGH!!! >_<

Why must every point I make be compromised by flawed typing?!

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: somebody
Subject: Re: Design patterns
Date: 5 Jul 2008 11:27:09
Message: <486f92cd$1@news.povray.org>
"Paul Fuller" <pgf### [at] optusnetcomau> wrote in message
news:486f6167$1@news.povray.org...
> Orchid XP v8 wrote:

> > For example, (A*B)^2 - 4*(A+B) = (A-B)^2. Obvious once you know, but
> > DAMN... I've have never thought of it!

> Well that is true for some values of A an B - But probably not as many
> as you think.
>
> Whereas (A+B)^2 - 4*(A+B) = (A-B)^2 is true a few more cases.

Still, not true for as many cases as

(A+B)^2 - 4*A*B = (A-B)^2


Post a reply to this message

From: Chambers
Subject: Re: Design patterns
Date: 5 Jul 2008 17:39:10
Message: <486fe9fe$1@news.povray.org>
Warp wrote:
> Primitive
>   '--> Line
>   '--> Rectangle
>   '--> Circle
>   '--> Union
>          '--Contains: List of <Primitive>

I was doing that before I knew what "Design Patterns" were.

>   The book Design Patterns is full of tidbits like this, making it
> potentially quite useful to someone.

Actually, I think it would be extremely beneficial to me, just for the 
standard terminology.  While there are patterns I don't know, more 
important to me is being able to communicate with other people the ideas 
in my head.

...Chambers


Post a reply to this message

From: Chambers
Subject: Re: Design patterns
Date: 5 Jul 2008 17:44:14
Message: <486feb2e@news.povray.org>
Orchid XP v8 wrote:
>>> For example, (A*B)^2 - 4*(A+B) = (A-B)^2. Obvious once you know, but 
>>> DAMN... I've have never thought of it!
>>>
>> Well that is true for some values of A an B - But probably not as many 
>> as you think.
>>
>> Whereas (A+B)^2 - 4*(A+B) = (A-B)^2 is true a few more cases.
>>
>> Unless you have redefined the * and + operators :)
> 
> NAAAAARGH!!! >_<
> 
> Why must every point I make be compromised by flawed typing?!
> 

Because you don't type enough?

I recommend you spend *more* time on these forums, and tell your boss 
you're improving your work skills :)

...Chambers


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.