Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'api.': 0.05; 'reason,': 0.07; 'defeating': 0.09; 'instances.': 0.09; 'latter': 0.09; 'measure': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'seemed': 0.09; 'uses.': 0.09; 'yeah,': 0.09; 'api': 0.11; 'bug': 0.12; 'itself.': 0.14; 'question.': 0.14; 'useful,': 0.14; '"code': 0.16; 'ass': 0.16; 'coupling': 0.16; 'discussion.': 0.16; 'exclusion': 0.16; 'it".': 0.16; 'kern': 0.16; 'matters,': 0.16; 'measures': 0.16; 'naming': 0.16; 'optional.': 0.16; 'php:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'underlying': 0.16; 'url:post': 0.16; ':-)': 0.16; 'so.': 0.16; 'wrote:': 0.18; 'discussion': 0.18; 'looked': 0.18; 'examples': 0.20; 'example': 0.22; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'error': 0.23; "aren't": 0.24; 'interpret': 0.24; 'java': 0.24; 'people,': 0.24; 'looks': 0.24; 'task': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'point': 0.28; 'function': 0.29; 'appear': 0.29; 'related': 0.29; "doesn't": 0.30; 'compared': 0.30; 'robert': 0.30; 'especially': 0.30; 'asked': 0.31; 'gives': 0.31; 'code': 0.31; '+0100,': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'themselves': 0.32; 'another': 0.32; 'up.': 0.33; 'cases': 0.33; 'checking': 0.33; 'fri,': 0.33; 'not.': 0.33; 'agree': 0.35; 'common': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'instances': 0.36; 'like,': 0.36; 'doing': 0.36; "i'll": 0.36; 'half': 0.37; 'so,': 0.37; 'being': 0.38; 'sometimes': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'bad': 0.39; 'guidance': 0.39; 'legitimate': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'according': 0.40; 'how': 0.40; 'tell': 0.60; 'first': 0.61; 'our': 0.64; 'telling': 0.64; 'more': 0.64; 'world': 0.66; 'believe': 0.68; 'press': 0.70; 'eyes': 0.78; 'eco': 0.84; 'goto': 0.84; 'harm.': 0.84; 'subject:skip:o 10': 0.84; 'terrible': 0.84; 'url:php': 0.85; 'novice': 0.91; 'received:86': 0.91; 'reducing': 0.93; 'wanting': 0.93; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robert Kern Subject: Re: object.enable() anti-pattern Date: Sat, 11 May 2013 20:55:49 +0100 References: <518a123c$0$11094$c3e8da3@news.astraweb.com> <518b32ef$0$11120$c3e8da3@news.astraweb.com> <518be931$0$29997$c3e8da3$5496439d@news.astraweb.com> <518c5bbc$0$29997$c3e8da3$5496439d@news.astraweb.com> <518c7f8e$0$29997$c3e8da3$5496439d@news.astraweb.com> <518cd360$0$29997$c3e8da3$5496439d@news.astraweb.com> <518df898$0$29997$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: cpc2-cmbg17-2-0-cust347.5-4.cable.virginmedia.com User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: <518df898$0$29997$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 69 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368302161 news.xs4all.nl 16010 [2001:888:2000:d::a6]:59042 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45151 On 2013-05-11 08:51, Steven D'Aprano wrote: > On Fri, 10 May 2013 18:20:34 +0100, Robert Kern wrote: > >> 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. > > But isn't that the case for all anti-patterns? > > We agree that GOTO is an anti-pattern. That doesn't mean that there > aren't valid reasons for using GOTO. Sometimes there are good use-cases > for GOTO that outweigh the harm. By calling it an anti-pattern, though, > we shift the onus onto the person wanting to use GOTO: justify why you > need it, or use something else. Yes, that was the point I was making. You seemed to be defining away the legitimate instances as not instances of the pattern at all because they were legitimate, and that appeared to me to be defeating the purpose of having the discussion. On a related note, I *don't* think it's a good idea to phrase it as "justify why you need it". I don't think that gives very good guidance to a novice when they are given the task of designing something. People can come up with a justification for just about anything, especially when they are only justifying things to themselves. I think it's more important to just talk about the situations where a pattern is useful, and the common situations where people, for whatever reason, *think* that a pattern is useful, but isn't. Naming it a Pattern or Anti-pattern is really just a measure of how bad the latter half of that is compared to the first half, and is less interesting than the discussion itself. That's why I had a bug up my ass about what looked like the exclusion of the "good" uses. It's the good examples that give novices an idea of what a good justification looks like, so they can tell if the justification they are giving themselves measures up. > Would you object less if I called it a "code smell" than an "anti- > pattern"? If so, I accept your criticism, and call it a code smell: the > less temporal coupling your API has, the better. That was not really my objection. I was objecting to the way you appeared to be defining the particular pattern in question. But as we appear to agree on the important matters, I won't press it further. >> That is why I asked for in-the-wild instances. > > How about this? > > http://legacy.thecodewhisperer.com/post/366626867/improving-clarity-by-removing-temporal-coupling There's something about Java mixedCase that makes my eyes glaze, so I'll take your word for it. :-) > Another example of temporal coupling is json_decode in PHP: you must > follow it by a call to json_last_error, otherwise you have no way of > telling whether the json_decode function succeeded or not. > > http://php.net/manual/en/function.json-last-error.php I suspect that the author might say something about error checking being optional. But yeah, terrible API. :-) -- 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