News for hackers. Stuff that matters.
Re:Ask HN: Best Way to Mock APIs in 2020? by emilsedgh on Sunday June 14, 2020 @05:26AM (#23516237)
I personally am not a fan of too many abstractions.

If the only reason for abstraction is testing, then mocking an interface seems like a more valid choice to me.

Re:Ask HN: Best Way to Mock APIs in 2020? by jjpe on Sunday June 14, 2020 @06:15AM (#23516489)
> I personally am not a fan of too many abstractions.

Then you're likely in the wrong business, since most of what programming is is dealing with the various facets of one abstraction or another.

Re:Ask HN: Best Way to Mock APIs in 2020? by emilsedgh on Sunday June 14, 2020 @08:03AM (#23517069)
Absolutely. I'm not saying I don't want to abstract anything or deal with any abstractions which can lead to ridiculous code [0].

I just prefer to abstract when I have more reasons that just testing. That can be done using mocking techniques.

https://docs.spring.io/spring/docs/2.5.x/javadoc-api/org/spr...

Re:Ask HN: Best Way to Mock APIs in 2020? by TomMarius on Sunday June 14, 2020 @06:38AM (#23516610)
This is definitely a valid approach to software development, e.g. in embedded development (where you still might need to call APIs).
Re:Ask HN: Best Way to Mock APIs in 2020? by xadoc on Sunday June 14, 2020 @05:33AM (#23516282)
The abstraction is there because in many static languages you will immediately have two implementations, the infrastructure one (database, API call, 3rd party) and the tests.