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,2a687662f09731bb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!newspeer.monmouth.com!news.tele.dk!news.tele.dk!small.news.tele.dk!irazu.switch.ch!news-zh.switch.ch!switch.ch!cernne03.cern.ch!cern.ch!news From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Ada Quality and Style book discussion ("_Type" suffix) Date: Fri, 18 Nov 2005 10:23:22 +0100 Organization: CERN - European Laboratory for Particle Physics Message-ID: References: <1132227241.9036.44.camel@sonnenregen> <437c877e$1_1@glkas0286.greenlnk.net> NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sunnews.cern.ch 1132305802 23527 (None) 137.138.37.241 X-Complaints-To: news@sunnews.cern.ch User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Red Hat/1.7.12-1.1.3.2.SL3 X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:6460 Date: 2005-11-18T10:23:22+01:00 List-Id: Brian May wrote: > Marc> (http://www.joelonsoftware.com/articles/wrong.html). > > Looks like a good article. I agree, but there is some bias in it, see below. > > In a strongly typed language, I would prefer to use different types, > so the compiler does the checking. I fully agree. Making wrong code *look* wrong is a good idea, but it is only half of the solution. Complete solution is making wrong code *fail to validate* in the automated way (compilation belongs to this). > However, if you have to use a language that isn't strongly typed, good > Hungarian notation looks like a good compromise. Fully agreed. The problem with this article is that it does not name the languages to which it mostly applies and instead makes an impression that it applies to every language. Certainly Hungarian notation (in its original sense) is a good compromise in C, PHP, Perl and other languages where you cannot express separate domains with separate types. But I consider it to be useless for languages that provide the way to separate domains of interest by defining separate types, possibly with dedicated functions as the only gateways for conversions between those domains. Ada is such a language. C++ is also such a language and the problem with this article is that it might suggest the opposite to those who don't know it. > With respect to his complaint on exception handling - I like the Java > model where every exception that can be raised by a function has to be > declared [...] Except that the exception is not necessarily a contract between the direct caller and that function. Consider the sorting procedure, which accepts, as a parameter, a comparator which might throw some exception: Caller -- catches/handles exception -> Sorting_Function(array, comparator) -> comparator.Compare(...) -- throws/raises exception The type of this exception is actually a contract between the caller of sorting function and the comparator. The sorting function itself should be completely transparent w.r.t. exception that is thrown/raised by comparator and catched/handled by the caller. Java got it wrong. > Nor does Ada have a > "finally" clause. Ada doesn't need it (nor C++). Finalizers + object lifetime controlled by scope is a superior tool. -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/