Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31594
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: What could be improved about the assert statement |
| Date | Tue, 21 Apr 2015 07:38:54 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 39 |
| Message-ID | <mh5cql$qri$1@dont-email.me> (permalink) |
| References | <assert-20150421090715@ram.dialup.fu-berlin.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Tue, 21 Apr 2015 11:37:57 +0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="27506"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180RR9ews9mHhsCcKr4EPj4" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
| In-Reply-To | <assert-20150421090715@ram.dialup.fu-berlin.de> |
| Cancel-Lock | sha1:46gq5Tek46KbfPrlER7UmxTybAA= |
| Xref | csiph.com comp.lang.java.programmer:31594 |
Show key headers only | View raw
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
Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread
Re: What could be improved about the assert statement Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-04-21 07:38 -0400
csiph-web