POV-Ray : Newsgroups : povray.off-topic : Design patterns : Design patterns Server Time
7 Sep 2024 07:24:19 EDT (-0400)
  Design patterns  
From: Darren New
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

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