Dangerous API Example

  • Opening up too much functionality is a bad idea
public class ExpressionEvaluator {

    private ParsedExpression parsedExpression;
    public double evaluateExpression(String expression) {
        // ... a bunch of parsing logic
        this.parsedExpression = new ParsedExpression(...);

        // ... math
        return result;
    }

    public ParsedExpression getExpression() {
        return this.parsedExpression;
    }
}

6 / 10