Re: General rule for constructors
- From: softwarepearls_com <info@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 15 Aug 2008 00:25:02 -0700 (PDT)
I'm a big fan of JB and his Effective Java.. but look at the JDK, and
work out the ratio of public constructors to factory methods. Public
constructors are in an overwhelming majority.. so clearly most people
are perfectly happy with constructors which, yes, hardcode the
implementation type in your logic. Even Bloch's Collections API uses
mostly the constructors approach.
Last but not least, I would argue strongly that software needs to be
thought of as fluid. With modern refactoring tools, we can quickly
make the kinds of changes to whole codebases which just a few years
ago would have been major headaches. JB's best advice is "If in doubt,
leave it out." So given that your static factories are a bit more
complex than plain constructors, I'd say leave them out (initially).
.
- Follow-Ups:
- Re: General rule for constructors
- From: Arne Vajhøj
- Re: General rule for constructors
- References:
- General rule for constructors
- From: pek
- General rule for constructors
- Prev by Date: Re: newInstance, generics, and "unchecked or unsafe operations"
- Next by Date: Re: what is Hibernate?
- Previous by thread: Re: General rule for constructors
- Next by thread: Re: General rule for constructors
- Index(es):
Relevant Pages
|