This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Get Programming with Java (MEAP only) and have Peggy Fisher on-line!
See this thread for details.
Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Observer Design Pattern--is my use-case good for ita good use case for ?  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 12825
211
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
4. Secure
5. Performant (see Three Rules of Optimization)
 
Do you pee on your compost? Does this tiny ad?
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!