From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ac4955b8006bd13c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Received: by 10.68.220.230 with SMTP id pz6mr10342349pbc.3.1338809996795; Mon, 04 Jun 2012 04:39:56 -0700 (PDT) Path: l9ni19433pbj.0!nntp.google.com!news2.google.com!goblin2!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Q: type ... is new String Date: Mon, 4 Jun 2012 11:39:56 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Injection-Date: Mon, 4 Jun 2012 11:39:56 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="3/9i4eU3tV30IAhXHAPg/g"; logging-data="25308"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/snDmUjSe4DhJL+o0rkFylMhLt4f8xc68=" User-Agent: Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT 30dc37b master) Cancel-Lock: sha1:ioC7aLVSdU2Bas5cBwQzI8kzStw= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2012-06-04T11:39:56+00:00 List-Id: On Wed, 30 May 2012 16:33:45 +0000, tmoran wrote: > Any comments on the effectiveness of using multiple types for different > categories of strings, rather than "String" all the time? A comment from a different angle... Some time ago, http://www.joelonsoftware.com/ was recommended to me as a good "inside voice" on (specifically C and C++) programming practice. And I started to enjoy these articles and agree with some of his points... Until I read http://www.joelonsoftware.com/articles/Wrong.html specifically this quote from a section oddly titled "The Real Solution"... "All strings that come from the user must be stored in variables (or database columns) with a name starting with the prefix "us" (for Unsafe String). All strings that have been HTML encoded or which came from a known-safe location must be stored in variables with a name starting with the prefix "s" (for Safe string)." Now it seems to me that he would be better off saying "type UnsafeString is new String;" and bypassing the rest of that (rather long) article entirely. And let the compiler catch the problems instead of uglifying the entire codebase so that he can tell programmers (I kid you not, it's a direct quote from the article!) "I know, it’s a little bit hard to see the wrong code at first, but do this for three weeks, and your eyes will adapt ..." Three weeks? Jeez. And you know that's just the tip of the iceberg. What's wrong with just letting the compiler find the wrong code? Now, we can debate the relative merits of "is new String" versus "is new Array <> of Character" but how do we get the message out there that recognized industry experts (and I'm not quoting "expert" because I believe he is, in his field) are recommending "Real Solutions" that impose weeks of painful and unnecessary work on unsuspecting programmers for ... what purpose? what gain? Or am I missing something in that article? - Brian