3 ms·
Spot on. You replace your "anemic way" with first-class functions and namespacing, it ends up being the same thing. With currying, you do away with OO and para
by hcarvalhoalves 11y ago
Spot on. You replace your "anemic way" with first-class functions and namespacing, it ends up being the same thing.
With currying, you do away with OO and parameter initialization altogether.
@curry
def SMTPSender(host, message):
...
emailSender = SMTPSender(host='localhost')
# partially evaluated fn with `host` fixed
emailSender(message=message)
- buffoon 11y agoThis is pretty much how we deal with this in a DI framework anyway. The constructor of the transport takes the host and the send method takes the message. emailSender = SMTPSender(host='localhost') # in container emailSender.send(message) # in implementation The consumer of the SMTPSender only interacts with the send() method.