object.enable() anti-pattern

Robert Kern robert.kern at gmail.com
Fri May 10 13:20:34 EDT 2013


On 2013-05-10 16:44, Serhiy Storchaka wrote:
> 10.05.13 15:19, Robert Kern написав(ла):
>> I'd be curious to see in-the-wild instances of the anti-pattern that you
>> are talking about, then.
>
> Many (if not most) GUI frameworks use this pattern.
>
>      button = Button("text")
>      button.setForegroundColor(...)
>      button.setBackgoundColor(...)
>      button.setFont(...)
>      button.setRelief(...)
>      button.setBorder(...)
>      button.setWidth(...)
>      button.setAction(...)
>      button.setMouseListener(...)
>      button.place(...)
>
> Another example is running a subprocess in Unix-like systems.
>
>      fork()
>      open/close file descriptors, set limits, etc
>      exec*()

According to Steven's criteria, neither of these are instances of the 
anti-pattern because there are good reasons they are this way. He is reducing 
the anti-pattern to just those cases where there is no reason for doing so. That 
is why I asked for in-the-wild instances. I should have qualified my sentence to 
include "according to your criteria" because people seem to be answering my 
query out of that context.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list