- Simplify by using methods, interfaces and composition.
- Luke created a
Decoder
type (which sounds more like an interface) which was a wrapper around anio.Reader
. That enabled him to create a composition such aserr = NewDecoder(file).Decode(p)
. I find that to be very elegant. - Jeremy implemented a
read
method for both thePattern
type and theTrack
types. I like Jeremy's method better because it adds extenisbility if theread
method had to be exported.
- Luke created a
- If I implemented this again, I would implement both
read
anddecode
methods onPattern
andTrack
types.Reader
andDecoder
are common interfaces in Go and it wouldn't take much to makePattern
andTrack
conform to those interfaces. - An
os.File
is anio.Reader
. This should have been obvious. binary.Read
requires fields to be exported, but you can define structs with exportable fields within a function, in which the structs themselves are still essentially private to the package (see Luke's solution in thereadHeader
andreadTrack
methods).
Monday, March 30, 2015
Lessons learned from the First Go Challenge. The winning entries were Luke Champine and Jeremy Jay. Runner up was Doug Cichon.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment