zopefoundation / zope.interface

Interfaces for Python
http://zopeinterface.readthedocs.io/
Other
325 stars 71 forks source link

Update the Adaptation docs to be more concrete. #233

Closed jamadden closed 3 years ago

jamadden commented 3 years ago

This should help provide better motivating use cases compared to the what the docs called the "silly" example of converting one number to another.

Examples inspired by https://glyph.twistedmatrix.com/2021/03/interfaces-and-protocols.html

Also some minor typo fixes and updates to comments. (One of which is for https://github.com/zopefoundation/zope.component/pull/53.)

jensens commented 3 years ago

I often explain adaption with the abstract factory design pattern. At least for those who learned about design patterns this simplifies understanding a lot.

jamadden commented 3 years ago

Agreed, that can be a good way to explain it.

I'm not sure that's the appropriate approach for this particular piece documentation though, because it's, well, abstract 😄

The original was trying to work through some concrete examples, with the intent of showing how things work and how you can use them. But upon re-reading it as a result of asking glyph to link to it, I found that the "concrete" examples, well, weren't (converting 0 into 42? Why would I want to do that?). I wanted to improve that and make the material more engaging so that hopefully people can more easily imagine how they might use it in their projects. Using points was the first example that came to mind (and it seemed pretty good because there are many representations for the same thing, but they all work slightly differently), but if there's a better one I'd be happy to make adjustments.

jamadden commented 3 years ago

Thank you for the reviews and comments.

jensens commented 3 years ago

Do not get me wrong, your example makes it way easier to understand. Thanks! It was just an idea....