Question
You are given a collection of interfaces and classes. Please review the code for: bugs algorithm and data structure issues general quality issues The interface
You are given a collection of interfaces and classes. Please review the code for: bugs algorithm and data structure issues general quality issues The interface IMarketDataFeed has a method tick this will fire any listeners registered with this component. AverageHalfSpreadIndicator is a class that subscribes to ticks received by IMarketDataFeed. It does some calculation when a tick is received and then notifies its listeners. This class should receive ticks from IMarketDataFeed This class should notify any listeners when it has performed its calculation The calculation should be optimal in speed Please also consider the the case where this code lives in: a single threaded environment a multi-threaded environment
public interface MarketDataFeed { String getStock(); void tick(MarketTick tick); void addListener(Function MarketTick, void> listener); public interface Indicator { void indicatorUpdated (Double value); public class MarketTick { public Double bid; public Double ask; public Double last; public void setBid(Double bid) { this.bid = bid; } public void setAsk(Double ask) { this.ask = ask; 3 public void setLast(Double last){ this. last = last; } public Double getBid() { return bid; 25 26 28 public Double getAsk() { return ask; 31 public Double getLast() { return last; 34 35 public Double getMid() { return (bid + ask) / 2; public class AverageHalfSpread Indicator { private ArrayList
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started