I have a use-case where as soon as my API receive a request, then i make make a call to some remote server, fetch the data, run my processing on that data and populate a response object. Now i need to do two things: 1) return this response object to the caller of my API which completes this flow in the same thread, 2) Also start a[b] Async thread to update this response object data's in Stringify manner to a cache . This second flow is fire and forget style. Here I am planning to use observer pattern in second flow ( the Async one).So that means as soon the response object is formed, it will call a subject class's setValue(..) method which will call its observer and in the observer's update() method i will span a thread which will update the cache.
Someone was saying using observer here i am increasing the time of processing here but i feel its provides loose coupling and extandability. Lets me know your thoughts so i can take it further.
My main considerations for design, in order of highest importance (1=most important):
1. Simplicity (meets the current requirements with least complexity)
2. Easy to understand
3. Easy to extend (loose coupling, cohesive, etc.)
5. Performant (see Three Rules of Optimization)
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck