Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.help Subject: Re: Good practice or not to close the file before System.exit(1)? Date: Fri, 22 Apr 2011 22:10:59 -0400 Organization: albasani.net Lines: 34 Message-ID: References: <87mxjjqmlf.fsf@merciadriluca-station.MERCIADRILUCA> <87ipu67b41.fsf@merciadriluca-station.MERCIADRILUCA> <87bozy9qek.fsf@merciadriluca-station.MERCIADRILUCA> <_9-dnRwCx6OvXCzQnZ2dnUVZ_sSdnZ2d@earthlink.com> <871v0u6m0y.fsf@merciadriluca-station.MERCIADRILUCA> <8739laf0xz.fsf@merciadriluca-station.MERCIADRILUCA> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net 7fDdyv5qpkF+9YsRhrs87zprXITjR39mRlJCj1xWeRAqgh3B+GagAvv3dxoZnfS0NlS4Qxmcki2qXUPb6+hi7dm4U7NNZPmp63+1Q5UjmpEHLcRSe1X/LZyZcvcrWYFJ NNTP-Posting-Date: Sat, 23 Apr 2011 02:10:58 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="PMIKT94appuJHk4Bw5wDVhT+KRcghynwMg0kBua10q3G8HlDv4GNi1yOuM9O6h9O3gnAdJ5myV7zuKZvQjI17fnU+3Kw/rrmkxoWwtpIlzadBnMfmuhlrh8YxEE2/2LA"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: Cancel-Lock: sha1:ZfhfbzfuHt89MnXPr2lRpBIGs8g= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.help:600 Patricia Shanahan wrote: > markspace wrote: >> Patricia Shanahan wrote: >> >>> >>> There is no problem using exceptions inside main, as long as you catch >>> them, so that they don't get thrown from main. >> >> During development, throwing exceptions from main is fine because it >> gives the developer the most about of useful information. > > Yes, I was over-simplifying a bit. I disagree. Throwing exceptions from main() provides no benefit that logging doesn't provide better. I'm using "main()" as a catch-all term for the top business layer of an application, be it a Java application, applet, web app, service or whatever. The observable behavior must conform to the problem domain being solved by the application. Emitting implementation-level messages at the business-domain level is inappropriate unless the business domain *is* the implementation. Even there, there is a conceptual difference between the business domain and the implementation domain. Design your business logic to be business logic. DO NOT make the mistake of "temporarily" inserting inappropriate code thinking, "We can pull this out later for production." Later doesn't come around enough to count on that. Design it right from day one and do not stray from being good. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg