CCob / bittrex4j

Java library for accessing the Bittrex Web API's and Web Sockets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

listeners and logic

marslep opened this issue · comments

Hey,
I take for example this listener:
private Observable exchangeSummaryStateBroker = new Observable<>();

why do we need a list of listeners? why it can't be just one?
same question goes to all the listeners..

another question:
what's your opinion regarding BittrexExchange. show it be one thread for marketdata and one for trading? or one thread can handle both?

I use the Observer pattern here in case users of the library have more that one part of code that's interested in the event. Limiting this to one would prevent you from doing this. Take for example a UI update interested in the latest price and a database module for logging the change in price. Sure this could all be done in the one callback, but not very good design in my opinion when it comes to single responsibility principle.

As far as single/multi threaded approach I think it depends on your program and if you are more reliant on the websocket or REST API's. The websocket logic is already asynchronous so no need to handle logic in separate threads.

thanks for the explantions 👍

No problem, I'll close for now.