Re:Interfaces in Go make it hard to navigate code
by signa11 on Monday May 27, 2013 @06:46AM
(#5774171)
> So all this time wasted trying to figure out what to pass into the Decode function could have been easily saved if os.File simply wrote “implements io.Reader” in the code itself.
imho, an "implements" keyword would be a bad choice to describe what interface a type implements partly because it introduces dependencies between types which might not exist. also, you don't have to design this type-hierarchy from the very beginning. you may notice a particular pattern in a bunch of libraries after they are written, and noticing this you can describe an interface which captures it. and in some cases it might not even be possible to annotate this type information, as the source-code might even be available...
imho, an "implements" keyword would be a bad choice to describe what interface a type implements partly because it introduces dependencies between types which might not exist. also, you don't have to design this type-hierarchy from the very beginning. you may notice a particular pattern in a bunch of libraries after they are written, and noticing this you can describe an interface which captures it. and in some cases it might not even be possible to annotate this type information, as the source-code might even be available...