Oh! I was wondering why Alex brought that up. It seemed way out of left field to me, since no one in the thread had been talking about static-method-only classes. I didn't think to look in the commits.
- Josh On 2019/01/26 16:41:56, Harbs <[email protected]> wrote: > OK. I’ll revert that change. > > I like the idea of private constructors. That does make more sense than > making the class abstract. Singletons was one of the areas that I was > wondering how we could improve, and this sounds like a great proposal. > > Thanks, > Harbs > > > On Jan 25, 2019, at 8:17 PM, Josh Tynjala <[email protected]> wrote: > > > >> I would never occur to me to use abstract for static-method-only classes. > >> In fact, to me, it makes those classes look like base classes that should > >> be subclassed before using. In Java they allow private constructors > >> instead and I believe that is the recommended pattern for > >> static-method-only classes. > > > > Interesting! I've never thought of using abstract in that way. I agree with > > your conclusion about classes with only static methods. When I see that a > > class is abstract, my first thought is that it is meant to be subclassed > > specifically so that it can be instantiated. I guess you could also make it > > final, but that's still potentially confusing. > > > > I was actually considering private constructors as a potential future > > enhancement. It would allow developers to prevent static-method-only > > classes from being instantiated, and it would enable a less-hacky way to > > implement the singleton pattern. > >
