Sossenbinder
strategy design pattern on discount
I agree, more context would be great. But I imagine this is some kind of uni / school task which just wants to see any usage of the pattern?
What I could think of would be having a sales component in your system which should dynamically react on specific pricing policies. That could be discounts, it could however also be different sales logic for different consumer markets, which might be extended without you wanting to touch the initial component tapping into these strategies
7 replies
✅ what's the difference?
With http through a controller you just get to benefit from the entire streamlined pipeline built around it, and your client will always receive some response back (Plus you are not bound to a more specific protocol in case you want to provide your API to someone else down the road)
4 replies
✅ what's the difference?
You can even have multiple hubs using a single websocket connection, if I recall correctly it will be multiplexed under the hood. You can also use signalr for bidirectional connection, but there are some drawbacks. First, if signalr uses e.g. websockets, you are bound to a long lasting http connection, and you will not be able to profit from something like round robin load balancing. Then you are also not forced to "respond" to a request, so the client might be left hanging unless you build a request reply setup yourself
4 replies
✅ Is this necessary?
I think disposing of the HttpClient will not dispose the response messages it "generated". Disposing the response message in turn will dispose underlying streams it keeps open. But I think it's actually relatively rare you need to work at this level, because most of the higher level abstractions around HttpClient will handle this for you, and only return e.g. the string to be converted to json
7 replies