eduncan911 / podcast

iTunes and RSS 2.0 Podcast Generator in Golang
MIT License
132 stars 35 forks source link

Tweak: move private methods from podcast.go to respected usage files #10

Closed eduncan911 closed 4 years ago

eduncan911 commented 6 years ago

When I originally write podcast.go, everything was in that one file.

As I started to add more and more functionality, it started to make sense to break out that extra functionality to dedicated files. E.g. item.go.

However, I forgot to move the required private methods used in such files from podcast.go out to their usage.

Example:

var parseDuration = func(duration int64) string needs to be moved to where it is being used, item.go.

Off Topic: You may be wondering why I use var parseDuration = func(duration int64) string to define my functions, instead of func parseDuration(duration int64) string. The reason is because of testability. By assigning it to a variable, it allows me to assign custom functionality during tests - e.g. to purposely break or purposely cause an invalid result - to see how the caller would react.

iwittkau commented 5 years ago

By assigning it to a variable, it allows me to assign custom functionality during tests - e.g. to purposely break or purposely cause an invalid result - to see how the caller would react.

12: To make sure a custom function implements the correct signature, I created function types for theses functions. By that you can require a ParseDurationFunc where it is needed. var parseDuration is now just a implementation of that function.