[Grok-dev] Feedback: A Grok-Centric Explanation of Adaptation

Philipp von Weitershausen philipp at weitershausen.de
Sun Jul 20 06:20:15 EDT 2008

Thanks to whomever wrote 
It's good to see more tutorials explaining adaption out there.

I only skimmed the article, mostly looked at the code. May I suggest a 
few improvements? The VGA port example could be improved a lot if

* IVGAPort would gain a description for that 'connect()' method that's 
used in plugLaptopIntoProjecter.

* The two models and the adapter implementation were removed. They don't 
seem to add any value to the understanding of adaption at this point. In 
particular, the emtpy adapter implementation is just plain confusing 
since it doesn't at all describe what an adapter really has to do.

* plugLaptopIntoProjecter were more concise and written in a realistic 
way. Here's how I would have written it:

   def plugLaptopIntoProjecter(laptop, projector):
       "Display your presentation on the wall!"

       vga_capable = IVGAPort(laptop, None):
       if vga_capable is None:
           print "You should get a MacBook Pro."

There's no need for that I...Port.providedBy() business. In fact, the 
whole point of adaption is to NOT care about the object you have at hadn 
and and simply trying to adapt it to something you DO care about 
instead. Whether or not this yield the identity relation (iow, getting 
the same object back) is irrelevant at that point.

More information about the Grok-dev mailing list