Richard Bucker

GoLang Polymorphic Factories

Posted at — Aug 30, 2013

I just finished watching one of the “Clean Code Talks” and while it looks like a grand idea and applicable in Go … the examples are trivial and does not lend itself to more complex ideas.Moments ago I determined that my execute() function was not really a class member function (but a factory of sorts) because there are a number of flow control features in the code. (1) is the user logged in (2) if the command is a GET then maybe the results are already cached (3) when the remote server responds will I get a result, stack dump, authentication/authorization error, session timeout; and so on.[UPDATE 2013-09-02] As I look at my current project and I consider the effort to replace every “if” statement with a polymorphic class I realize it’s probably more viral to fork all that code rather than finding a better way to test or even find a better way to write the code in the first place. (this is one place where erlang inspired and other functional/matching languages excel.)