Interface extension
Posted
by
user877329
on Programmers
See other posts from Programmers
or by user877329
Published on 2012-12-13T18:25:39Z
Indexed on
2012/12/13
23:19 UTC
Read the original article
Hit count: 275
Suppose that I have an input stream interface, which defines a method for reading data. I also have a seekable interface which defines a method for seeking. A natural way of defining a input file is then to implement both input stream and seekable.
I want to construct a data decoder from the input stream interface so I can read data from a file or from another stream. The problem is that I also want to implement seek functionality to the data decoder, since I want to be able to step individual records not raw bytes. This is not possible if I only provide an input stream, which does not have the bytewise seek method.
Should I skip the seekable interface and add the seek method to input stream instead and force all streams to at least leave it as a nop.
© Programmers or respective owner