Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #11516

Re: Blocks for scope control

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Blocks for scope control
Date 2012-01-20 08:41 +0100
Message-ID <9nsk4fFganU1@mid.individual.net> (permalink)
References <dBCQq.122$d%2.16@newsfe07.iad> <jev7op$j4k$1@news.albasani.net> <IRHQq.2650$2C.1194@newsfe20.iad> <jevoes$qru$1@news.albasani.net> <2P3Sq.1782$lS6.832@newsfe20.iad>

Show all headers | View raw


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/

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Blocks for scope control Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-01-15 11:50 -0400
  Re: Blocks for scope control Robert Klemme <shortcutter@googlemail.com> - 2012-01-15 17:10 +0100
  Re: Blocks for scope control Robert Klemme <shortcutter@googlemail.com> - 2012-01-15 17:32 +0100
    Re: Blocks for scope control Lew <noone@lewscanon.com> - 2012-01-15 11:21 -0800
    Re: Blocks for scope control Robert Klemme <shortcutter@googlemail.com> - 2012-01-16 07:59 +0100
  Re: Blocks for scope control markspace <-@.> - 2012-01-15 09:57 -0800
    Re: Blocks for scope control Lew <noone@lewscanon.com> - 2012-01-15 11:28 -0800
  Re: Blocks for scope control Lew <noone@lewscanon.com> - 2012-01-15 11:00 -0800
    Re: Blocks for scope control Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-01-15 17:49 -0400
      Re: Blocks for scope control Lew <noone@lewscanon.com> - 2012-01-15 15:45 -0800
        Re: Blocks for scope control Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-01-19 21:54 -0400
          Re: Blocks for scope control Robert Klemme <shortcutter@googlemail.com> - 2012-01-20 08:41 +0100
            Re: Blocks for scope control Lew <noone@lewscanon.com> - 2012-01-20 15:24 -0800
            Re: Blocks for scope control Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-01-20 19:30 -0400
              Re: Blocks for scope control Lew <noone@lewscanon.com> - 2012-01-20 15:54 -0800
      Re: Blocks for scope control Robert Klemme <shortcutter@googlemail.com> - 2012-01-16 07:55 +0100
        Re: Blocks for scope control Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-01-19 21:16 -0400
          Re: Blocks for scope control Robert Klemme <shortcutter@googlemail.com> - 2012-01-21 13:25 +0100
            Re: Blocks for scope control Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-01-21 10:41 -0400
              Re: Blocks for scope control Robert Klemme <shortcutter@googlemail.com> - 2012-01-22 13:03 +0100
  Re: Blocks for scope control Roedy Green <see_website@mindprod.com.invalid> - 2012-01-16 06:09 -0800
    Re: Blocks for scope control Henk van Voorthuijsen <voorth@xs4all.nl> - 2012-01-16 07:03 -0800
  Re: Blocks for scope control Arne Vajhøj <arne@vajhoej.dk> - 2012-01-17 18:43 -0500
  Re: Blocks for scope control Lew <noone@lewscanon.com> - 2012-01-20 11:05 -0800
  Re: Blocks for scope control Gene Wirchenko <genew@ocis.net> - 2012-01-20 12:11 -0800
  Re: Blocks for scope control Arne Vajhøj <arne@vajhoej.dk> - 2012-02-06 21:24 -0500

csiph-web