Return-Path: Delivered-To: apmail-incubator-aries-dev-archive@minotaur.apache.org Received: (qmail 50801 invoked from network); 5 Oct 2009 17:20:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Oct 2009 17:20:18 -0000 Received: (qmail 67297 invoked by uid 500); 5 Oct 2009 17:20:18 -0000 Delivered-To: apmail-incubator-aries-dev-archive@incubator.apache.org Received: (qmail 67235 invoked by uid 500); 5 Oct 2009 17:20:18 -0000 Mailing-List: contact aries-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: aries-dev@incubator.apache.org Delivered-To: mailing list aries-dev@incubator.apache.org Received: (qmail 67225 invoked by uid 99); 5 Oct 2009 17:20:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Oct 2009 17:20:18 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [76.13.13.93] (HELO smtp110.prem.mail.ac4.yahoo.com) (76.13.13.93) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 05 Oct 2009 17:20:09 +0000 Received: (qmail 95182 invoked from network); 5 Oct 2009 17:18:47 -0000 Received: from cpe-174-099-058-061.nc.res.rr.com (dwoods@174.99.58.61 with plain) by smtp110.prem.mail.ac4.yahoo.com with SMTP; 05 Oct 2009 10:18:47 -0700 PDT X-Yahoo-SMTP: sCI.ryiswBB7FW.DxjU523c87MI- X-YMail-OSG: J4PlJGQVM1ksUy5rtskLTi9nZB84Gwp7vPA1.ErMCB.PHCc7DCoeX2szyDim1IKu__z543PPkq709CpcwOmIJDJsjg_LNAy9Dc_i.9Xrl8QsGI2I7vIWtDNU4jvEkTSUddH7DkVBxdgA8gWBuNCghewVOzMfk7UaQ4S8_SpkNCziU8pILuPH_Rt02uEJYJrQAtyTrXgDFebG8Yw8vGHCQzcsTQRa7UX9ZNKl3ekzBffvskXXVztjtZ5.XIFnCecqLKr4hkkDZLbzcTica992fiivYv4WtDlle8tFyKrj9EKpbhnrmfWeaoOiPOd7M8cmP1sdJtJbFCH8.aw1Yn20ahILHqB66h6TbjiuxSUIyWb_OAfNCKpl8M4jZjIK7Y9cwLeXvZN5IH0j9hrrlbZoxhP6DHWZF_mJ3TpDr8T61e9Xfw-- X-Yahoo-Newman-Property: ymail-3 Message-ID: <4ACA2A77.9000505@apache.org> Date: Mon, 05 Oct 2009 13:18:47 -0400 From: Donald Woods User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: aries-dev@incubator.apache.org Subject: Re: asserts References: <2D1AC299-C2ED-4E8C-8885-74999392EA0B@toolazydogs.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Why not just throw a RuntimeException, with an informative message as to what the invalid value was and what was expected? We use that method over asserts all the time in OpenJPA. -Donald Alan D. Cabrera wrote: > I wouldn't say that one is better than the other. I think that both > have their places. > > I use assertions to catch catastrophic conditions early on. Note that I > use the word catastrophic. The idea is that if you get values that are > known a priori to be bad and will definitely cause the server to barf > it's better to complain right then and there rather than complain at > some later point in time when the server tries to use them. > > > Regards, > Alan > > > > On Oct 5, 2009, at 2:09 AM, David Bosschaert wrote: > >> I guess I don't mind this but I wonder what you are trying to achieve? I >> mean, you have a running system and all of a sudden you get an assertion >> failure. What are you going to do? >> >> I always wondered whether code assertions are really the right tool >> for the >> job... >> In my opinion it would be better to add a bunch of unit tests to the >> system >> and put all your assertions in there. That way your assertions are >> part of >> the continuous build & test cycle and when there is an assertion >> failure you >> will actually have the opportunity to do something about it: fix the code >> and rerun the tests... >> >> Best regards, >> >> David >> >> 2009/10/3 Alan D. Cabrera >> >>> Does anyone mind if I start putting in assert statements in the code? >>> >>> >>> Regards, >>> Alan >>> >>> > >