Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 32B54200C8C for ; Tue, 6 Jun 2017 22:31:59 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3180D160BC6; Tue, 6 Jun 2017 20:31:59 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 51EE0160BB7 for ; Tue, 6 Jun 2017 22:31:58 +0200 (CEST) Received: (qmail 11602 invoked by uid 500); 6 Jun 2017 20:31:57 -0000 Mailing-List: contact dev-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list dev@flex.apache.org Received: (qmail 11590 invoked by uid 99); 6 Jun 2017 20:31:57 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jun 2017 20:31:57 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id A08111AFDD9 for ; Tue, 6 Jun 2017 20:31:56 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -2.4 X-Spam-Level: X-Spam-Status: No, score=-2.4 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.8, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id HwH92haQFUvU for ; Tue, 6 Jun 2017 20:31:55 +0000 (UTC) Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 7F0D85F5B8 for ; Tue, 6 Jun 2017 20:31:54 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id v104so11246115wrb.0 for ; Tue, 06 Jun 2017 13:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=s2T162/HanSxISQ0okBm7SC+t7xLhe6dbiQW1mYTilc=; b=p45bjnDMD/7nTqYNyPe0F1OeMPBgjAEjiIXxf4FD/JW4i2n1sRK8IrhNFirM4TIzeP MWa6AkENX1l4yhdqkwv5NuxDTvfpxKxEYiYwXGWpO3gVJ2QZnwcDJkl8s0f5SjrzYnet 1USZg28vrf7Q1TR+p5EzMLycxTRogX/eDCX5WAGZNUXIeZtU/I5/uSfa9czxALXFND/Y 3lyCm2+/0ewwa8BCh4cUlV3rYln2DllrDmX/McQJMmj/byfahYBM93uP8kv9KIzNM3vN tbbgDx7hmN6BjJAeWlKNBSPcW5jziR57AEEEkZSOvfBmsL+9m7a9Yx5hlVjcCG2nMD71 M00g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=s2T162/HanSxISQ0okBm7SC+t7xLhe6dbiQW1mYTilc=; b=qmbI/AkD8TxC1d6+kxobxevVWup0GpHapOJGikikJVcSLB+TW+yIGXhdh1srslDAB9 np4v4ls40EGpPWTvTwIVBoejwH2SrIvBLzsVbFrrtwk92NAuoy/nTCKprJ7UM0abEyeJ 0+vstxAAqDX8TGQ025bAxosKA+wDQjq4OQG0YPokPKehWmDKIQFlI/yV87XZAuxgDcdk NAjEBT/B7bb0GIHyEyTfm7vMDW6R/WUeXEQbd5uyxu/8EAfumQzAD9TWy/YWPIUTVdFJ EbrVtu2AdOYmJPsQxxGOaZgaOsONUN6CI0bF+n/YkdKzdZs4zlpOTkh33Jc30BtmE8Sm YzrQ== X-Gm-Message-State: AODbwcA7YD6+sxXfZj8ArLdrVJRk0CdEheKUzOGt1bo32Et3VTOQMzQM dSim+06XKSYnizkgN4c= X-Received: by 10.223.130.151 with SMTP id 23mr19194165wrc.16.1496781106630; Tue, 06 Jun 2017 13:31:46 -0700 (PDT) Received: from [10.0.0.4] ([185.120.126.37]) by smtp.gmail.com with ESMTPSA id e19sm14670687wma.25.2017.06.06.13.31.45 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 13:31:46 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: Beads and DRY (was Re: [FlexJS] Removing PasswordInputBead has no effect) From: Harbs In-Reply-To: Date: Tue, 6 Jun 2017 23:31:43 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <24FF0747-F3FF-40DC-B53B-E36BD216168C@gmail.com> References: To: dev@flex.apache.org X-Mailer: Apple Mail (2.2104) archived-at: Tue, 06 Jun 2017 20:31:59 -0000 There=E2=80=99s actually two ways of adhering to DRY: 1. Subclassing 2. Utility classes. In FlexJS we have a preference towards utility classes. (and I=E2=80=99d = like to see even more) Besides very often doing a better job than = subclasses in terms of avoiding code-repeat, it=E2=80=99s also more = geared towards functional programming which is a good thing. It allows = for easier testing and the like. Lots of small utility classes is also = much more modular. So, utility classes solves PAYG, DRY and improved testability. An all = around win=E2=80=A6 As far as beads go vis a vis subclassing, I=E2=80=99d say it depends: 1. The the vast majority of the functionality could be in utility = classes, then I=E2=80=99d go for two separate classes. 2. If two versions of the same bead-type are unlikely to be used in the = same app, I=E2=80=99d avoid subclassing as well. 3. If it=E2=80=99s likely to have both versions of the beads in use and = utility classes are impractical, I=E2=80=99d lean towards subclassing. My $0.02 Harbs > On Jun 6, 2017, at 6:52 PM, OmPrakash Muppirala = wrote: >=20 > In an attempt to simplify the pattern, can we say: >=20 > Strands =3D components > Beads =3D functionalities >=20 > All components dont need all functionalities. We add functionalities = to > components on a Pay As You Go (PAYG) basis. >=20 > This is achieved through composition (the classical OOP paradigm) >=20 > That is, a Strand is composed of several Beads. Beads are added to = Strands > only when necessary. >=20 > That leaves us with how we build the Beads themselves. I suggest we > encourage inheritance for Beads so as to follow the Dont Repeat = Yourself > (DRY) principle. >=20 > Thanks, > Om >=20 >=20 > On Jun 6, 2017 8:03 AM, "Alex Harui" wrote: >=20 > I agree we have to be concerned about DRY. Research into optimal = patterns > for creating common flavors of beads would be very helpful. The = compiler > might be able to help as well. >=20 > -Alex >=20 > On 6/6/17, 6:52 AM, "Josh Tynjala" wrote: >=20 >> The way that beads work means that we will frequently "violate" DRY, = as I >> understand it. FlexJS is designed to have multiple beads that = implement >> the >> same thing in different ways. The simplest bead will be designed to = be >> never removed and it probably won't include any properties to = configure >> its >> behavior. A more complex bead might include some of the same code = from the >> simplest bead, but it will also be designed to be removed, but still = not >> configured. An even more complex bead will include all three (the = core >> feature, removal, and properties to configure). There might even be a >> fourth one that can't be removed, but has properties to configure. = Going >> even further, there might even be variations with different subsets = of >> properties that can be configured. >>=20 >> Ideally, we'd find a way to reuse some of the code from the simpler = beads. >> It might be possible to subclass them, for instance. However, unless = the >> simplest beads are designed for it, reusing their code may not be >> possible. >> In fact, designing them in a way that they can be extended may = violate >> PAYG >> instead because it may require adding code that isn't always needed. = In >> that case, there's no option except to repeat some code. >>=20 >> - Josh >>=20 >> On Tue, Jun 6, 2017 at 12:02 AM, Justin Mclean = >> wrote: >>=20 >>> Hi, >>>=20 >>>> Unless something is functionality that you would (virtually) always >>> need, it=E2=80=99s a separate bead. >>>=20 >>> So for CCS we have border, does everyone need borders? Why do we = only a >>> sub set of the font attributes included? Some people are not going = to >>> use >>> all of them or in fact any of them and some other may need other >>> properties >>> so why are they not seperate? Not that I think these should be = removed >>> into seperate parts. The issue is just about every feature you can = name >>> is >>> going to optional to someone. So I think we near a clearer = definition of >>> what PAYG is. >>>=20 >>> Another example why for instance was flexGrow and flexShrink added = in to >>> the CSS code? Shouldn't they be implemented in line with the PAYG >>> principal >>> in another class? And there are numerous other examples of this. I = feel >>> that PAYG is not being applied consistently and seems selective on = who >>> is >>> making the contribution. >>>=20 >>>> PAYG is already well understood >>>=20 >>> IMO it has not been clearly defined. Alex has described in various = ways >>> as >>> it size / runtime cost only to move to goal posts. I for one would = like >>> a >>> clearer definition of it. >>>=20 >>>> All functionality should be implemented as beads when practical. = Beads >>> should be as modular as possible with the smallest possible = functional >>> set. >>>=20 >>> What about the cost of violating DRY or the single responsibility >>> principal which two beads do similar things? Is it really OK to add >>> technical debt / penalise users of a new feature when it would be = less >>> cost >>> modifying/improving an existing bead at a much smaller cost? How do = you >>> discourage copy paste coding? >>>=20 >>> Thanks, >>> Justin