From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Maintaining implementations of similar utility functions like json-fetch Date: Sat, 27 Jan 2018 17:09:11 +0100 Message-ID: <87po5v1dy0.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efT2b-0005fz-3h for guix-devel@gnu.org; Sat, 27 Jan 2018 11:09:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efT2Z-0003LQ-VX for guix-devel@gnu.org; Sat, 27 Jan 2018 11:09:17 -0500 Received: from hera.aquilenet.fr ([2a0c:e300::1]:39634) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1efT2Z-0003KT-NT for guix-devel@gnu.org; Sat, 27 Jan 2018 11:09:15 -0500 In-Reply-To: (Jelle Licht's message of "Fri, 26 Jan 2018 16:28:28 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Jelle Licht Cc: guix-devel Hello! Jelle Licht skribis: > I noticed that there are currently two very similar functions for fetching > json data; `json-fetch' in (guix import json) and `json-fetch*' in (guix > import github). > > Some things I noticed: > - Dealing with http error codes seems to be a bit more robust in > `json-fetch*'. > - Making sure that (compliant) servers give responses in the proper format > seems more robust in `json-fetch' due to using Accept headers. > - Dealing with the fact that json responses are technically allowed to be > lists of objects, which `json-fetch' does not handle gracefully. > > For this issue specifically, would it make sense to combine the two > definitions into a more general one? Definitely, we should just keep one. It=E2=80=99s not even clear how we en= ded up with the second one. > My more general concern would be on how we can prevent bug fixes only bei= ng > applied to one of several nearly identical functions. IOW, should we try = to > prevent situations like this from arising, or is it okay if we somehow ma= ke > sure that fixes should be applied to both locations? We should prevent such situations from arising, and I think we do. The difficulty is that avoiding duplication requires knowing the whole code base well enough. Sometimes you just don=E2=80=99t know that a utility function is available so you end up writing your own, and maybe the reviewers don=E2=80=99t notice either and it goes through; or sometimes you= need a slightly different version so you duplicate the function instead of generalizing it. Anyway, when we find occurrences of this pattern, we should fix them! Thanks, Ludo=E2=80=99.