well that's to build a config, do you expect it to do it for each request?

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-03-19 15:18 GMT+01:00 Werner Keil <[email protected]>:

> Just a question of preference, some (or several) projects tend to hide the
> constructor, others accept it and yet other ones offer even both ways;-D
>
> Configuration conf = new ConfigurationBuilder().build();
> int bar1 = conf.getInteger("foo.bar");
>
> From my earlier example for simplicity would be equally fine.
>
> One has to add, the static factory allows optimization especially for a
> default case to cache something if it won't change for the lifetime of an
> app/VM.
> If you call new ConfigurationBuilder() you always need to instantiate a new
> object, only the underlying JDK may help you save resources if it can.
>
> Werner
>
>
>
>
>
>
> On Thu, Mar 19, 2015 at 3:06 PM, Oliver B. Fischer <
> [email protected]
> > wrote:
>
> > Hi,
> >
> > I don't see the value of the whole discussion.
> >
> > Why can I not simply say
> >
> > new ConfigurationBuilder();
> >
> > What is wrong about it?
> >
> > Viele Grüße
> >
> > Oliver
> >
> >
> > Am 19.03.15 um 14:59 schrieb Werner Keil:
> >
> >> Why would you get a builder FROM a configuration? I'd expect a
> >> configuration from a builder;-)
> >> So it'll be a builder "for" a particular configuration.
> >>
> >> valueOf() and getInstance() have been the two most common static
> factories
> >> and till Java 5 or even 6 they were the only ones used at all, not just
> by
> >> JDK.
> >> While Josh Bloch started "playing" with of() in a single place (EnumSet)
> >> it
> >> also got probably even more frequent in the .NET world.
> >> Dim xyz As Nullable(Of Date)
> >>
> >> is the way to use Nullable in VB.net. C# has a shortcut via "?". Both
> are
> >> vaguely comparable to the new Optional class in Java 8. Where of() is
> also
> >> used. Mostly new types or elements of Java 8 start getting it, so you
> may
> >> call it less "common" for the rest of the platform.
> >>
> >>
> >> If you prefer valueOf(), that would be just as good. from() or to() only
> >> apply to conversions, they just make no sense in other cases.
> >>
> >> The new Lambda packages of Java 8 are full with of() and even classes or
> >> inner types called Of*, etc.
> >>
> >> Most of its builders are static inner .Builder types btw, see
> >> static <T> Stream.Builder
> >> <http://docs.oracle.com/javase/8/docs/api/java/util/
> >> stream/Stream.Builder.html>
> >> <T>builder
> >> <http://docs.oracle.com/javase/8/docs/api/java/util/
> >> stream/Stream.html#builder-->
> >> ()
> >> Returns a builder *for *a Stream.
> >>
> >>   Aside from any particular names it should be as easy as Typesafe
> Config:
> >>
> >> Config conf = ConfigFactory.load();
> >> int bar1 = conf.getInt("foo.bar");
> >> Config foo = conf.getConfig("foo");
> >> int bar2 = foo.getInt("bar");
> >>
> >> but if you prefer the term Builder, it should be equally
> straightforward.
> >>
> >> Configuration conf = ConfigurationBuilder.getInstance().build();
> >> int bar1 = conf.getInteger("foo.bar");
> >>
> >> would require auto-boxing but compile  a comparable Tamay example.
> >> Assuming
> >> ConfigurationBuilder needs to instanciate first.
> >>
> >> Typesafe's factory is a simple static class that takes various
> arguments.
> >>
> >> Oh btw, mostly used by Eclipse and OSGi, but there you see default no-op
> >> factory methods called *getDefault*() almost everywhere. But then
> calling
> >> interfaces ISomething is also nearly unknown outside .NET or Eclipse;-)
> >>
> >> Werner
> >>
> >>
> >>
> >>
> >>
> >> On Thu, Mar 19, 2015 at 2:29 PM, Romain Manni-Bucau <
> >> [email protected]>
> >> wrote:
> >>
> >>  2015-03-19 14:19 GMT+01:00 Werner Keil <[email protected]>:
> >>>
> >>> well let say common is subjective since it is as common to not use it.
> >>>
> >>> here semantically it is wrong since you dont get the builder of a
> >>> configuration but you get a builder from a configuration.
> >>>
> >>> more root semantic would be unwrap or something like that - we can
> still
> >>> use but istoo technical IMO.
> >>>
> >>>
> >>> using the constructor just makes this topic closed IMO. The static
> method
> >>> really brings nothing here.
> >>>
> >>>
> >>> [email protected]
> >>> since
> >>> me;-)
> >>> [email protected]>
> >>> also
> >>> other
> >>> a
> >>> (in
> >>> using
> >>> a
> >>> to
> >>> given
> >>> to
> >>> input,
> >>> don't
> >>> can
> >>> the
> >>> ebove
> >>> we
> >>> the
> >>>
> >>
> > --
> > N Oliver B. Fischer
> > A Schönhauser Allee 64, 10437 Berlin, Deutschland/Germany
> > P +49 30 44793251
> > M +49 178 7903538
> > E [email protected]
> > S oliver.b.fischer
> > J [email protected]
> > X http://xing.to/obf
> >
> >
>

Reply via email to