Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Blocks for scope control Date: Fri, 20 Jan 2012 08:41:01 +0100 Lines: 44 Message-ID: <9nsk4fFganU1@mid.individual.net> References: <2P3Sq.1782$lS6.832@newsfe20.iad> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net kcImVZrgEGA8SZgCeVwGqwGU5Wlck+n8OCch5xQDG70rorzw4= Cancel-Lock: sha1:L3CDxS2eBns8iiax4I/ehudqMjo= User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 In-Reply-To: <2P3Sq.1782$lS6.832@newsfe20.iad> Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11516 On 20.01.2012 02:54, Arved Sandstrom wrote: > Another decent reason, in my opinion, is if the management of them is > not disciplined. An organization that doesn't even wonder whether they > are disciplined enough to manage assertions in code isn't, and others > that do ask the question may decide that they are not. I think this does not necessarily need to be handled on organization level. Why make it so big? Every developer can help himself and their colleagues by using them in a reasonable way. > What I mean by this is, assertions are easy to put in. They are not > always correct when put in, and they have to be maintained in any case > as code changes (or at least removed if necessary). Existing obsolete > assertions need to be taken into account when adding new ones in the > same class or package, because if you enable one then you may enable > more. Or you remove old ones you don't understand, if you trust yourself > to understand the business rules from 4 years ago well enough to > classify the assertions as being defunct. Assertions also have the effect that they force you to think about certain - possibly not obvious - properties of the code / class at hand when you change the code. So while an assertion may look tricky it actually helps you when modifying code to not forget important aspects. This may be more tedious but it certainly helps code robustness in the long run. > Let me put it this way: I would feel good about looking at code that had > assertions in it if I saw that they were also commented where necessary, > including traceability notes where that makes sense, *and* were > supported by unit tests that exercised the assertions. I view assertions in part also as documentation. Often no additional commenting is needed. I frequently have a private boolean method "classInvariant" or with other (hopefully telling) name with checks and has documentation of its own. In these cases you have the name of the method plus documentation on the method. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/