Presentation to the OMG's MARS Task Force in June, 2010 on proposed improvements to the Java API to the OMG's Data Distribution Service specification (DDS).
Benefits of “close” instead of factory method:
Familiar from java.io, javax.jms
Can’t get it wrong by using wrong factory
Important to keep everything as interface or stateless abstract class:
Don’t constrain implementations
Don’t risk bugs
Context allows multiple DDS implementations (including multiple versions of the same impl.) to coexist.
Also allows implementations to be transparently unloaded when no longer used.
If you don’t care about the parameters, just use wildcard—less hassle than in C++.
If you do care, you can bind them to preserve type safety.
First, show how it works.
Then, show why it works that way.