Created
September 15, 2012 21:34
-
-
Save jwilger/3729891 to your computer and use it in GitHub Desktop.
Quick API design poll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A) Instantiate Connection object directly, have it know whether it | |
# needs to use a "test mode" implementation internally. | |
my_api = MyAPI::Connection.new(:mode => :test) | |
# B) Directly instantiate a "test mode" connection object. In | |
# production, a call to `MyAPI::Connection.new` would be used instead. | |
my_api = MyAPI::TestConnection.new | |
# C) The MyAPI module has a factory method that knows whether to return | |
# a `Connection` or a `TestConnection` (or a `Connection` in test | |
# mode?). | |
my_api = MyAPI.connect(:mode => :test) | |
# D) The MyAPI module has a factory method that returns a | |
# `TestConnection`. It would have a similar `#connect` method that | |
# returns a `Connection`. | |
my_api = MyAPI.connect_test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment