From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Filipe Silva Newsgroups: gmane.emacs.help Subject: Re: Seeking Advice about refactoring and advice snippet Date: Fri, 10 Feb 2017 14:22:19 -0200 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1486743786 25907 195.159.176.226 (10 Feb 2017 16:23:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 10 Feb 2017 16:23:06 +0000 (UTC) Cc: Help Gnu Emacs mailing list To: Yuri Khan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 10 17:23:02 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ccDyM-0006R1-W1 for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Feb 2017 17:22:59 +0100 Original-Received: from localhost ([::1]:44671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccDyS-0004D4-IS for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Feb 2017 11:23:04 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccDxl-0004C1-VN for help-gnu-emacs@gnu.org; Fri, 10 Feb 2017 11:22:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ccDxk-00021x-TA for help-gnu-emacs@gnu.org; Fri, 10 Feb 2017 11:22:21 -0500 Original-Received: from mail-ot0-x22e.google.com ([2607:f8b0:4003:c0f::22e]:36295) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ccDxk-00021U-Nh for help-gnu-emacs@gnu.org; Fri, 10 Feb 2017 11:22:20 -0500 Original-Received: by mail-ot0-x22e.google.com with SMTP id 32so31716468oth.3 for ; Fri, 10 Feb 2017 08:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+SiLNGkEAHJNnJ1s+kuWi9zgVeSItp0hSKD8p71Mr80=; b=Lxznj3Dc9mljhoad36fnWapjmUwv84J03heP0R0T/R2O97s2JN3qHimKouyAR4zKvK ixc5ZkNcyEgsVkE+w4KwHQbPQ2y62jqA6bPDVPfyyWL69WhT+9JgcjVmaTdWBUn3b8pL 9lna/1EUFui4n61UGDDh1SJ3KwVFpSR5zP2Db6kJw8pBkRrkv/VFw0OH+uj9zrp5prE9 58J5GSwK69v88RzghW1e0PR0KmCXTYa8k0hodHzl9tUcHlr+LhJATt2hfq084cZg72bQ p3qIhFiZ78unp6bgbI3AU5BJ4KcrLNi1qHDr6rXWS4OjZsPLmUWIvX+UCxUWsmI7lSox Cx+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+SiLNGkEAHJNnJ1s+kuWi9zgVeSItp0hSKD8p71Mr80=; b=gEiVSWH8qkL1Igyp7HdxwB/bnLqffTf33Vcb4TsYEX5cZTXIuG9f8y1mOhG4bf6GQ+ FKSF9V9qL5WPmFdAIFYSvs5uWZwug27YxeXsoBg2x4Ft85nQqxIl5jPTLgElVvwgSuXH jUqfWy1KE2vuci/C3R/bUqka42GVYXUnZN5BIWcETQNLO4ARydvZpfhn4+LpfFt2snVC WC/vm23YXdhOHHTGvjpSeIv5tsvHDiDdfmjD7kaRYuGPpfHrVoCmzSRP8PYKKne3xtlH tE8jXAVUjBN2QOSOSwS9O6ffC3y5zMbXs83ZJcWyU/0Qj802zNG5mYBYEZLCVtmivmKL RedA== X-Gm-Message-State: AMke39nfot8evhIe5Ot5ECf0HjUPKAQzCWVErdUDiKERebSsPyCsJQnprlCEyLFYEku6edBhGUG6XlDsTBO4Uw== X-Received: by 10.157.4.53 with SMTP id 50mr5682973otc.234.1486743740086; Fri, 10 Feb 2017 08:22:20 -0800 (PST) Original-Received: by 10.157.56.242 with HTTP; Fri, 10 Feb 2017 08:22:19 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c0f::22e X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112291 Archived-At: Hi Yuri, this WET principle is very insteresting and I should apply it more. Thanks for sharing it! In the interest of learning elisp properly though, I'd like to be able to perfom this simple refactoring, because that would improve my knowledge of elisp. This is a very simple operation that I should be capable of performing. []s Filipe On Fri, Feb 10, 2017 at 11:08 AM, Yuri Khan wrote: > On Fri, Feb 10, 2017 at 6:43 PM, Filipe Silva > wrote: > > > The problem is that these lines: > > > > (message "DENIED! don't kill my precious *scratch*!!") > > (apply buffer-assassin arguments)))) > > > > Are repeated in both functions, so I thought that I could apply the DRY > > principle > > I cannot say anything useful regarding your approach, but I can=E2=80=99t= help > noticing that you are trying to reduce duplication of two lines in two > functions. This is not likely to help maintainability significantly. > > In Extreme Programming circles, there is a principle called Three > Strikes And You Refactor, which says that you only have enough data > for a meaningful refactoring when you see three instances of the same > pattern. > > Until you encounter that third instance, you could follow the WET > principle instead: Write Everything Twice :) >