Dependency Injection - Code Illustration Using Java

Code Illustration Using Java

Using the stock trading example mentioned above, the following Java examples show how coupled (manually injected) dependencies and framework-injected dependencies are typically staged.

The following interface contracts define the behavior of components in the sample system.

public interface IOnlineBrokerageService { String getStockSymbols; double getAskingPrice(String stockSymbol); double getOfferPrice(String stockSymbol); void putBuyOrder(String stockSymbol, int shares, double bidPrice); void putSellOrder(String stockSymbol, int shares, double offerPrice); } public interface IStockAnalysisService { double getEstimatedValue(String stockSymbol); } public interface IAutomatedStockTrader { void executeTrades; }

Read more about this topic:  Dependency Injection

Famous quotes containing the words code and/or illustration:

    Acknowledge your will and speak to us all, “This alone is what I will to be!” Hang your own penal code up above you: we want to be its enforcers!
    Friedrich Nietzsche (1844–1900)

    Each truth that a writer acquires is a lantern, which he turns full on what facts and thoughts lay already in his mind, and behold, all the mats and rubbish which had littered his garret become precious. Every trivial fact in his private biography becomes an illustration of this new principle, revisits the day, and delights all men by its piquancy and new charm.
    Ralph Waldo Emerson (1803–1882)