Calculator API 

Based on the previous discussion, we can describe the Calculator API in the Calculator interface as follows:

public interface Calculator {  int multiplyByTwo(int i);}static Calculator createInstance(){  return CalculatorFactory.create();}

If the constructor of the Calculator implementation requires parameters, we would add them to the create()  factory method and to the createInstance() static method of the interface. 

When only one implementation of the Calculator interface exists, the previous API declaration would be enough. But when you give the client a choice of two or more implementations, as we have described previously, then the API should also include the description of calculator.conf configuration file.

The configuration ...

Get Introduction to Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.