Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Needs help in editing Date: Sun, 26 Jun 2011 16:35:51 -0400 Organization: albasani.net Lines: 31 Message-ID: References: <1021f122-3898-4fc9-93ed-ac1aa9403b82@q15g2000yqk.googlegroups.com> <4e03bfb7$0$23665$426a34cc@news.free.fr> <4e03c0a3$0$23665$426a34cc@news.free.fr> <4389af7c-3124-42ea-b092-54999cff42c2@z7g2000prh.googlegroups.com> <4e04e54a$0$6275$426a34cc@news.free.fr> <4e078d2f$0$4541$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.albasani.net /qTCEL9T4eY2Z1WWOcSWi3Bxf8I9dH9n/SYcNWKm6k+PhB3g6pK+jIQojCr6v7E6dNUFfaEpmppJUrwQPIw7oW8DJUDh8h0cclwI7uuXHFXttCrkUOfV9w2udO5otj+v NNTP-Posting-Date: Sun, 26 Jun 2011 20:35:47 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="Qcz7G4vX4fu5tZ5jf/sCP/rxty9196HSNJuxbWD1yfCvBW9AAIDcD7UGDcly5nqjaOxi3S7KEkTNJzRMZcyyLLV2d+nAixB3ABTgH3UV8WjmiISDnGj9pKqJ2gYHnZ8o"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 In-Reply-To: <4e078d2f$0$4541$426a74cc@news.free.fr> Cancel-Lock: sha1:z31O6+CbRFCsqo141YsAzhdSZ2Y= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5695 Aéris wrote: > Lew a écrit : >> Reflection is mostly avoidable. A little light use of >> 'Class#newInstance()' with package-private builders called by a factory >> method isn't very risky and avoids the typical mad craziness of looking >> up 'Method' or 'Constructor' instances. If you're going down that >> latter route, leave programming to those better equipped for it. > > This is what I say… > On clean code, Class#newInstance + setter avoid reflection. > But on the craps given code, empty constructor is not available, so > Class#newInstance is not usable in this case… I note that you make no effort to evaluate my suggestion against yours for their relative merits. You can use the existing type that has no no-arg constructor by using a builder inside a factory method. No weird reflection needed - just a builder that knows how to construct the target object. Since the builder is a *new* type, your comment that it doesn't have this or that is ridiculous. You create the builder with a no-arg constructor and build what you need, returning an instance of the target type to the factory method. How about you speak to that suggestion, hm? -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg