Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 72265 invoked from network); 18 Dec 2004 00:07:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 18 Dec 2004 00:07:09 -0000 Received: (qmail 84189 invoked by uid 500); 18 Dec 2004 00:07:01 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 84093 invoked by uid 500); 18 Dec 2004 00:06:59 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 84060 invoked by uid 99); 18 Dec 2004 00:06:59 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of jak-ant-dev@m.gmane.org designates 80.91.229.2 as permitted sender) Received: from main.gmane.org (HELO main.gmane.org) (80.91.229.2) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 17 Dec 2004 16:06:31 -0800 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1CfS7A-0004lc-00 for ; Sat, 18 Dec 2004 01:06:28 +0100 Received: from 209-6-203-157.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.203.157]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 18 Dec 2004 01:06:28 +0100 Received: from jesse.glick by 209-6-203-157.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 18 Dec 2004 01:06:28 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: dev@ant.apache.org From: Jesse Glick Subject: Re: [Patch] ChangeLogParser - hiding field Date: Fri, 17 Dec 2004 19:06:21 -0500 Organization: Sun Microsystems Lines: 54 Message-ID: References: <41C2514B.8080109@it.fts-vn.com> <1103284226.4266.40.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 209-6-203-157.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020 X-Accept-Language: en-us, en In-Reply-To: <1103284226.4266.40.camel@localhost.localdomain> Sender: news X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Just jumping in here... :-) kj wrote: >>>-class ChangeLogParser { >>>+public class ChangeLogParser { > > No really, just habit - company standards where I've worked in past etc. Did your company produce Java components with publicly visible APIs they were committed to preserving indefinitely? Seriously, making and keeping a decent Java API is *hard* and almost no "good style for programmers" books give you workable recommendations. I've been working on NetBeans core APIs for several years and often regret some method that seemed harmless four years ago and was made public without careful planning. Not to mention the mess that is javax.swing.** Javadoc that it is too late to fix. It is a bit unfortunate that the Ant team never published guidelines separating real APIs (intended for task authors, embedders, listener creators, etc.) from implementation (e.g. task classes). So now we are stuck with the situation that anything which is technically accessible in the Ant codebase is considered a full API automatically. Generally, assume everything should be private and final unless you know how it should be called or overridden. In practice, static methods are usually not much of a burden to maintain public; instance methods and constructors more so; and nonfinal classes are very hard to maintain compatibly, since there is a huge amount of runtime semantics which subclasses typically rely on and which has to be documented explicitly and probably can never be changed. > I suppose it could expose the class more than was intended, but again > the only real rationale for this was that I was looking at the class and > it's completely automatic (for me) to specify an exact access modifier > for everything as shows your exact intentions. For a top-level class, lack of a written access modifier *is* the one and only way to specify that it should be package-private, which is the most restrictive mode for it. When writing a new class, start with static final class Foo {} or for a nested class private static final class Foo {} and go from there. It is just unfortunate that the Java language has unsafe defaults for these modifiers. -J. -- Jesse Glick x22801 NetBeans, Open APIs --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org