Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 70775 invoked from network); 12 Jan 2011 18:28:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Jan 2011 18:28:34 -0000 Received: (qmail 45121 invoked by uid 500); 12 Jan 2011 18:28:33 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 44987 invoked by uid 500); 12 Jan 2011 18:28:32 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 44979 invoked by uid 99); 12 Jan 2011 18:28:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jan 2011 18:28:32 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of phil.steitz@gmail.com designates 209.85.214.43 as permitted sender) Received: from [209.85.214.43] (HELO mail-bw0-f43.google.com) (209.85.214.43) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jan 2011 18:28:26 +0000 Received: by bwz14 with SMTP id 14so806616bwz.30 for ; Wed, 12 Jan 2011 10:28:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=rW95Up2HCAuwlkOj8/ogN0aab7n3QBPlq1yBWwKYw48=; b=jAkQWGBKulqwNpESWHdicSSA73tPFzyCo8ReC0f7INYLL6RqylB1ktPLn1MlP9hACo 80cO+al3lOOkAbdj7KVQWtNtLXdWWRhjQGUfPjT+M3lncE804dOByHp0WC3uUIYJXcwC EXI/fBYBYmDSa8WBBkpnvF9AQ3mmpjeeBLln4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=X+rXvGQx+8dmuzXD3UfAMrMnRqMnfMD64y1sENiXWpBsEUW2NgzAe0X2Q9gYZFH/5b d24Idksvimi0U+6Bdp2M0DgFMqDYCf7eOxFvvrywI2ie4BZmbfqzv6Jqwqnfh0haw8u2 RYbWlpFQaUl78rglw/UO78eImHPPn+Nz8f7Ig= MIME-Version: 1.0 Received: by 10.204.51.11 with SMTP id b11mr1016670bkg.129.1294856885412; Wed, 12 Jan 2011 10:28:05 -0800 (PST) Received: by 10.204.48.141 with HTTP; Wed, 12 Jan 2011 10:28:05 -0800 (PST) In-Reply-To: <20110111151549.GI22299@dusk.harfang.homelinux.org> References: <20110111151549.GI22299@dusk.harfang.homelinux.org> Date: Wed, 12 Jan 2011 13:28:05 -0500 Message-ID: Subject: Re: [Math] Coding and documenting guidelines From: Phil Steitz To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Tue, Jan 11, 2011 at 10:15 AM, Gilles Sadowski wrote: > Hi. > > Is there a document presenting best practices for writing code for CM? > Right now I'm thinking about the recent overwrites of Javadoc comments; s= o I > think that it could be useful to lay out what should be there (beyond the > obvious that "everything should be documented"). Yes. See http://commons.apache.org/math/developers.html. > > A few things that come to mind: > > * All exceptions that could be thrown must be documented in a "@throws" t= ag, > =A0indicating all the possible causes of the exception (such as the > =A0assumed preconditions) +1 - tricky to do in all cases since we have abandoned checked exceptions and unchecked exceptions can propagate unexpectedly through API layers. I do agree with the spirit of this, though and would say *must* for exceptions that may immediately be thrown as a result of precondition violation. This follows from the principles laid out in the Developer's Guide. > > * The "@param" tag should not contain redundant information (such as > =A0preconditions since they must be documented in a "@throws" tag). For the rest of this, I would prefer that we stick with our previously agreed convention (stated in the doc above) to just follow the Sun conventions. It will be much easier for contributors and those applying patches if we just follow the standard conventions. A couple of areas where we have slipped a bit over the years that I would rather apply energy to than formatting are the following (from the Developers' guide): # All component contracts must be fully specified in the javadoc class, interface or method comments, including specification of acceptable ranges of values, exceptions or special return values. # External references or full statements of definitions for all mathematical terms used in component documentation must be provided. # Implementations should use standard algorithms and references or full descriptions of all algorithms should be provided. # Additions and enhancements should include updates to the User Guide. I have an open action, for example, to define precisely what we mean by "support" for distributions. What is important to me is the content of the javadoc, not so much what elements include what info. I think, for example, http://s.apache.org/S39 is fine. In some cases, the preconditions of a method involve multiple parameters or other context info so it is more convenient to state them in the main method description. Again, the important thing is to clearly state (or reference) a) relevant mathematical definitions and algorithms b) preconditions and c) exceptions or NaN returns when preconditions are not met. Phil --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org