Last active
December 27, 2015 19:39
-
-
Save mlopes/7378989 to your computer and use it in GitHub Desktop.
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
# Tell - The de-coupling allows me to write the example without having to write an example of the Keychain class | |
class EncryptionKey: | |
def __init__(self, keychain): | |
self.keychain = keychain | |
def decrypt(self, password): | |
if _decrypt(password): | |
self.keychain.unlock() | |
# Ask - The tight coupling causes strong dependencies | |
class Keychain: | |
def unlock(self, password): | |
try: | |
decrypted_key = encrypted_key.decrypt(password) | |
self.locked = False | |
except: | |
self.locked = True | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment