Closed kolbis closed 6 years ago
Hi @kolbis,
I'm not sure why this design was chosen, I assume it was due to simplicity, so that we don't have to implement a derived type for every command. Maybe that's easier to do in Java thanks to the ability to create anonymous implementations for abstract base classes? @JorritSalverda, can you chime in on this one?
As to your last question: we are running this on production in many APIs, and multiple commands are handling over 100 requests per second.
I did this mostly because I'm not a big fan of inheritance. I definitely favour composition over inheritance - although that doesn't really apply here as there's little composition going on :) - after having seen so many bad uses of inheritance cornering big software projects into a certain solution without an easy way out.
Thank you both for the responses. The original implementation of Netflix is using inheritance (and IMHO this makes sense in this case, in order to keep code cleaner).
On Netfix java port, you wrap each "critical code" with a command. In other words, you need to create a new class which inherits from HystrixCommand and place your execute and fallback logic inside this class. The approach which was selected for this port differs, so you do not need to create command classes.
IMHO, having also the "inheritance" approach is valuable and provides more flexibility and readability (especially for complex behaviors).
My last question refers to production readiness of this port.
Thanks!