commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Bluett-Duncan <jbluettdun...@gmail.com>
Subject Re: [lang][collections] SortedProperties
Date Tue, 18 Jul 2017 22:50:16 GMT
>
> Yes, of course, that's one way to go and also create a bunch of methods to
> delegate to the wrapped Properties... BUT I cannot pass this object to a
> method typed with "Properties".
>

Oh, that's a fair point. You've convinced me. :)

On 18 July 2017 at 23:44, Gary Gregory <garydgregory@gmail.com> wrote:

> On Tue, Jul 18, 2017 at 11:27 AM, Jonathan Bluett-Duncan <
> jbluettduncan@gmail.com> wrote:
>
> > I would strongly discourage subclassing `Properties` and instead I'd
> > encourage composing it into the proposed `SortedProperties` class, as
> > subclassing classes which weren't designed for inheritance is risky
> > according to Effective Java 2nd Edition, Items 16 and 17.
> >
> > So for example:
> > ```
> > public final class SortedProperties {
> >   private final Properties properties;
> >   ...
> >   public static SortedProperties from(Properties properties,
> > Comparator<...> keyComparator) {
> >     ...
> >     return new SortedProperties(...);
> >   }
> >   private SortedProperties(...) { ... }
> >   ...
> > }
> > ```
> >
>
> Yes, of course, that's one way to go and also create a bunch of methods to
> delegate to the wrapped Properties... BUT I cannot pass this object to a
> method typed with "Properties".
>
> Gary
>
>
> > On 18 July 2017 at 19:25, Rob Tompkins <chtompki@gmail.com> wrote:
> >
> > >
> > >
> > > > On Jul 18, 2017, at 4:43 AM, Jörg Schaible
> <joerg.schaible@bpm-inspire.
> > > com> wrote:
> > > >
> > > > Hi Gary,
> > > >
> > > > Gary Gregory wrote:
> > > >
> > > >> Hi,
> > > >>
> > > >> I'd to have a new class called SortedProperties that extends
> > > >> java.util.Properties.
> > > >>
> > > >> Should that go in [lang] or [collections]?
> > > >>
> > > >> I first thought [lang], but it _is_ a collection after all.
> > > >>
> > > >> Gary
> > > >
> > > > for me it's [collections]. [collections] is like [lang] also an
> > > extension to
> > > > the Java runtime, specialized for the collection/map/array stuff of
> > > > java.util. Especially since we tried to strip [lang] down and have
> > > already
> > > > moved stuff now into more specialized components.
> > >
> > > I'm stuck in the in-between here with the following thought: HashTable
> > > certainly feels like a collection of objects, but it clearly extends
> > > Dictionary and isn't in the collections family. But we are in java.util
> > > here and not in java.lang, so that feels more like it could be in
> > > collections. Plus properties are essentially a map, despite they're
> being
> > > implemented on top of hashtable.
> > >
> > > -Rob
> > >
> > > >
> > > > Cheers,
> > > > Jörg
> > > >
> > > >
> > > > ------------------------------------------------------------
> ---------
> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message