Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.help Subject: Re: Sorry for disturbing this page.....I need help Again Date: Fri, 11 Nov 2011 07:18:08 -0800 (PST) Organization: http://groups.google.com Lines: 56 Message-ID: <19992967.114.1321024688323.JavaMail.geo-discussion-forums@prmf13> References: <508339c1-3b13-4c0f-a2b4-d3af4be61ab6@e2g2000vbb.googlegroups.com> Reply-To: comp.lang.java.help@googlegroups.com NNTP-Posting-Host: 173.164.137.214 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1321024768 26172 127.0.0.1 (11 Nov 2011 15:19:28 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 11 Nov 2011 15:19:28 +0000 (UTC) In-Reply-To: <508339c1-3b13-4c0f-a2b4-d3af4be61ab6@e2g2000vbb.googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.164.137.214; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.help:1324 I don't have your answer yet, but I do have advice about posting. 1) Fix your indentation and follow the conventions for it. If you want people to help you analyze your code, you should make the effor= t to make your code readable. 2) The subject line should summarize the problem or insight contained in th= e body. "sorry for disturbing this page" is a weak title. It says nothing about wh= at you're going to ask or say, there's no need to apologize anyway, and thi= s isn't a "page". 2) Follow the Java code conventions. Class names should start with an upper-case letter, non-constant variables = and methods should start with a lower-case letter. If you want people to help you analyze your code, you should make the effor= t to make your code readable. The Java code conventions are available on the Oracle website. 3) Constructors are for construction. You do a lot of logic in the constructor. That's a very bad practice. You= are doing logic in an incomplete object. That can lead to weird bugs. Pr= obably not the one you're facing now, but why take chances? Constructors should only do the business of creating a complete object in a= valid initial state. That can involve some hairy logic occasionally, for = example opening a remote resource, but that should be rare and only when ju= stified in terms of establishing a valid initial state. Everything else, nearly all action, should happen only after the constructo= r completes. This is especially important in multi-threaded code such as yours. All kin= ds of concurrency guarantees are null and void until construction completes= . 4) Don't declare unnecessary variables, and don't declare them only at the = front. Variables, if and when needed, should be declared in the narrowest appropri= ate scope and near the point of use. This is covered in Joshua Bloch's /Effective Java/ (2nd ed.), which no one = should skip if they dare to call themselves a Java programmer. These cleanup steps at a minimum will help make it easier to spot where thi= ngs go wrong. --=20 Lew