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:
“Wise Draco comes, deep in the midnight roll
Of black artillery; he comes, though late;
In code corroborating Calvins creed
And cynic tyrannies of honest kings;
He comes, nor parlies; and the Town, redeemed,
Gives thanks devout; nor, being thankful, heeds
The grimy slur on the Republics faith implied,
Which holds that Man is naturally good,
Andmoreis Natures Roman, never to be
scourged.”
—Herman Melville (18191891)
“What is character but the determination of incident? What is incident but the illustration of character?”
—Henry James (18431916)