- Simplify by using methods, interfaces and composition.
- Luke created a
Decodertype (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
readmethod for both thePatterntype and theTracktypes. I like Jeremy's method better because it adds extenisbility if thereadmethod had to be exported.
- Luke created a
- If I implemented this again, I would implement both
readanddecodemethods onPatternandTracktypes.ReaderandDecoderare common interfaces in Go and it wouldn't take much to makePatternandTrackconform to those interfaces. - An
os.Fileis anio.Reader. This should have been obvious. binary.Readrequires 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 thereadHeaderandreadTrackmethods).
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:
Comments (Atom)
