Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.java.programmer > #5695

Re: Needs help in editing

From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.programmer
Subject Re: Needs help in editing
Date 2011-06-26 16:35 -0400
Organization albasani.net
Message-ID <iu8573$b8e$1@news.albasani.net> (permalink)
References (2 earlier) <4e03c0a3$0$23665$426a34cc@news.free.fr> <4389af7c-3124-42ea-b092-54999cff42c2@z7g2000prh.googlegroups.com> <4e04e54a$0$6275$426a34cc@news.free.fr> <iu7qcd$g7l$1@news.albasani.net> <4e078d2f$0$4541$426a74cc@news.free.fr>

Show all headers | View raw


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

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Needs help in editing Eric <ehtisham@gmail.com> - 2011-06-23 11:25 -0700
  Re: Needs help in editing Aéris <aeris@imirhil.fr> - 2011-06-24 00:35 +0200
    Re: Needs help in editing Aéris <aeris@imirhil.fr> - 2011-06-24 00:39 +0200
      Re: Needs help in editing lewbloch <lewbloch@gmail.com> - 2011-06-24 08:42 -0700
        Re: Needs help in editing Aéris <aeris@imirhil.fr> - 2011-06-24 21:28 +0200
          Re: Needs help in editing Lew <noone@lewscanon.com> - 2011-06-26 13:30 -0400
            Re: Needs help in editing Aéris <aeris@imirhil.fr> - 2011-06-26 21:49 +0200
              Re: Needs help in editing Lew <noone@lewscanon.com> - 2011-06-26 16:32 -0400
              Re: Needs help in editing Lew <noone@lewscanon.com> - 2011-06-26 16:35 -0400
  Re: Needs help in editing rossum <rossum48@coldmail.com> - 2011-06-23 23:42 +0100
  Re: Needs help in editing William Colls <william.colls@rogers.com> - 2011-06-23 22:40 -0400
    Re: Needs help in editing Lew <noone@lewscanon.com> - 2011-06-26 13:40 -0400
  Re: Needs help in editing Roedy Green <see_website@mindprod.com.invalid> - 2011-06-27 20:05 -0700
  Re: Needs help in editing Lew <noone@lewscanon.com> - 2011-06-28 00:09 -0400

csiph-web