Skip to content

Instantly share code, notes, and snippets.

@eamonnfaherty
Forked from jonnyreeves/gist:2043975
Created March 15, 2012 13:37
Show Gist options
  • Save eamonnfaherty/2044238 to your computer and use it in GitHub Desktop.
Save eamonnfaherty/2044238 to your computer and use it in GitHub Desktop.
Factory Methods
//if you can use polymorphism instead of a switch
return _appRequest.marshaller(_payloadSerializer);
//If your TargettedAppRequest class is part of another api use an adapter wrapper
return new MyAppRequestAdapter(_appRequest).marshaller(_payloadSerializer);
//thinking behind - factories are handy for complex object creation and for families of related objects but for this I would use an adapter class with the switch inside it - I find them easier to read.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment