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


Groups > comp.lang.java.programmer > #31594 > unrolled thread

Re: What could be improved about the assert statement

Started byEric Sosman <esosman@comcast-dot-net.invalid>
First post2015-04-21 07:38 -0400
Last post2015-04-21 07:38 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.java.programmer

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: What could be improved about the assert statement Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-04-21 07:38 -0400

#31594 — Re: What could be improved about the assert statement

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2015-04-21 07:38 -0400
SubjectRe: What could be improved about the assert statement
Message-ID<mh5cql$qri$1@dont-email.me>
On 4/21/2015 3:13 AM, Stefan Ram wrote:
>    I just wrote these assert statements:
>
> assert row >= 0: "row > 0";
> assert row <  3: "row <= 3";
> assert col >= 0: "col > 0";
> assert col <  3: "col <= 3";
> assert state[ row * 3 + col ]== Square.Z: "state[ row * 3 + col ]== Square.Z";
> ...
> assert list.size() > 0: "list.size() > 0";
> ...
> assert worst.size() > 0: "worst.size() > 0"';
> ...
> assert evaluation.board != null : "evaluation.board != null";
> ...
>
>    Maybe, you now already can guess, what I don't like!
>
>    There could be some convention, like for example that
>
> assert row >= 0:;
>
>    means that the text between »assert« and »:« should
>    be trimmed and than be taken for the text of the
>    assert message.

     Although I use `assert' liberally, I can't recall ever using
the colon-and-message part.  IMO, an `assert' failure is a message
from developer to developer, not from application to user, and the
developer who receives it will be looking at the AssertionError --
which will point him straight at the `assert' statement itself,
right there in the source.  Any further (mis-)information seems
pointless.  (In particular, a message that simply repeats the same
source text he's staring at would be pointless.)


-- 
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM

[toc] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web