aws

http://status.aws.amazon.com/ https://www.expeditedssl.com/aws-in-plain-english
kenny 2020-04-09T20:12:56.083700Z

Curious how folks who use Cognitect's aws-api handle testing. We are currently using with-redefs on invoke while testing. This feels gross. I'm considering creating a protocol that has an invoke method. We'd then extend the Client type to use this protocol and use our own invoke method instead of the invoke function in aws-api. This would let us create mock clients during tests, removing the need for with-redefs.

2020-04-09T20:18:56.084200Z

(aws/invoke (aws/client {:api :dynamodb :http-client MY_MOCK_HTTP_CLIENT}) {:op :ListTables})
Something like that ^ ?

ghadi 2020-04-09T20:20:01.085400Z

IMHO you should abstract in front of aws-api and let it be an impl detail

kenny 2020-04-09T20:20:07.085700Z

I suppose. I'd prefer to work at the aws-api client level than the request level.

ghadi 2020-04-09T20:20:18.086Z

don't try to intercept individual ops, but make pluggable application level things

ghadi 2020-04-09T20:22:40.087200Z

💯 2
kenny 2020-04-13T20:31:16.099400Z

Have you applied something similar to Datomic?

ghadi 2020-04-13T20:34:05.099600Z

no, mostly because the API to datomic is already pretty generic data

ghadi 2020-04-09T20:22:50.087700Z

small example of pluggable impls ^

kenny 2020-04-09T20:24:10.088500Z

Hmm. That's an interesting pattern. Essentially all effects become protocols?

ghadi 2020-04-09T20:49:09.088900Z

i'm not making prescriptions about all

ghadi 2020-04-09T20:49:37.089500Z

but i do think that coupling to aws-api, or clj-http, or any X library, is a bad idea

ghadi 2020-04-09T20:51:39.090300Z

program to abstractions, not concretions

jaihindhreddy 2020-04-10T11:46:40.092300Z

It is something similar to what Rich Hickey said a lot of times. Clojure is an improvement on the classic Perlis quote "It is better to have 100 functions operate on one data structure than to have 10 functions operate on 10 data structures." Clojure improves this by providing 100 fns on no data structure. The fns instead depend on abstractions like clojure.lang.IPersistentMap, clojure.lang.ISeq etc.

2020-04-10T16:16:36.092500Z

https://en.wikipedia.org/wiki/Dependency_inversion_principle (program to abstractions, not concretions). You can apply this principle to "abstraction" in this conversation, i.e. Clojure Protocols or Java Interfaces are implementation details of the abstract concept of "abstraction" 🙂

1
kenny 2020-04-13T20:36:22.099800Z

@dchelimsky Are there any other resources on that pattern that you know of that apply to functional programming and/or Clojure?

kenny 2020-04-13T20:42:45.100Z

Looking for things that help me think about what the abstractions are. A good point in the wiki is: > Implementing generic interfaces everywhere in a project makes it harder to understand and maintain. At each step the reader will ask themself what are the other implementations of this interface and the response is generally: only mocks.

jaihindhreddy 2020-04-14T05:08:04.100200Z

I feel it's a bad abstraction if it's not self-explanatory and requires readers to ponder the possible implementations to understand the abstraction. Where and how to abstract is a very hard problem indeed. Zach Tellman gave an excellent talk on the topic: https://www.youtube.com/watch?v=x9pxbnFC4aQ Rich Hickey's talks have also help me a lot in thinking about these things. These in particular: Simple Made Easy: https://www.youtube.com/watch?v=kGlVcSMgtV4 Design, Composition, and Performance: https://www.youtube.com/watch?v=MCZ3YgeEUPg

ghadi 2020-04-09T20:56:39.090600Z

actually I will make a prescription @kenny :

ghadi 2020-04-09T20:57:15.091400Z

grep for with-redefs in your projects and parameterize those things you find

👍 1
2
kenny 2020-04-09T20:59:34.091600Z

I could swear I've head this elsewhere 🙂 I quite like this train of thought. Is this from a talk or blog or simply a product of your own creation?

mruzekw 2020-04-09T22:32:49.091900Z

Sounds like something Rich Hickey would say