A
Antti S. Brax
I noticed recently something that could qualify as an anti
pattern (it's an instance of "designing for the future"). Please
comment.
I have a class which is not constrained by any interface. It has
a method which returns an InputStream. The implementation of the
class always returns a ByteArrayInputStream. Because the
designer of the class does not let me know the full capabilities
of the returned object I have to treat the returned object as a
plain InputStream and cannot take advantage of the information
that comes with a ByteArrayInputStream (mainly the available()
method).
Because of this I either have to use a lot of instanceof or end
up with an inefficient solution.
The designer of the class prepared for the situation where his
own implementation changes. The implementation never changed.
Poorly performing code resulted.
pattern (it's an instance of "designing for the future"). Please
comment.
I have a class which is not constrained by any interface. It has
a method which returns an InputStream. The implementation of the
class always returns a ByteArrayInputStream. Because the
designer of the class does not let me know the full capabilities
of the returned object I have to treat the returned object as a
plain InputStream and cannot take advantage of the information
that comes with a ByteArrayInputStream (mainly the available()
method).
Because of this I either have to use a lot of instanceof or end
up with an inefficient solution.
The designer of the class prepared for the situation where his
own implementation changes. The implementation never changed.
Poorly performing code resulted.