API Design

Exercises

Circuits

Design an API for modeling combinational logic circuits consisting of logic gates so that the model can be used to compute the output value of the logic function it represents for the given input values.

The API has to support at least the following gates:

Testing Circuits

Write test functions for the following tasks:

Fuzzy Circuits

Modify the boolean circuit into fuzzy circuit, so that it computes on floating point numbers in the range 0.0 to 1.0 represented as double values. To preserve backwards compatibility, the operations with booleans have to continue to work – false should be treated as 0.0 and true as 1.0.

The basic elements need to be modified to work with doubles as follows:

The API has to support single creation, i.e., it should be possible to create a single circuit which can be later evaluated using both boolean and double inputs.

Testing Fuzzy Circuits

Write test functions for the following tasks:

File Path API

Design API (classes, functions, …) for Windows file path manipulations

What are the requirements?

* path composition from elements
* getting path components (drive, directories, filename, extension)
* conversion between relative and absolute path

Extension: port to Unix environment

CSV Writer

Design API for writing CSVs.

What are the requirements?

Write code that uses your API (use GitLab snippets).

Write the actual API.

System Information

Design API for querying current system version (i.e. application needs to do platform-specific operation).

What are the requirements?

Write the API.

Running External Applications

Design API for running and controlling external applications (popen).

What are the requirements?

Write code that uses your API.

Write the actual API.

Benchmarking Harness

Design API for a harness which can execute benchmarks and collect timing (and other information) related to benchmark execution.

What are the requirements?

Write code that uses your API.

Write the actual API.

Benchmarking Harness Plugins

Extend the harness to enable changing the output format, control the number of repetitions, and provide additional information related to benchmark execution.

What are the requirements?

Write code that uses your API.

Write the actual API.

VFS

Design API that would be provided by OS VFS layer to end-user applications.

What are the requirements?

What API would be required from the concrete file systems?

Write both APIs.

DNS

Design API for management of DNS records.

What are the requirements?

Write code that uses your API.

Write the actual API.

REST API Middleware

Design “middle” API to simplify writing REST API bindings.

NOT this level

class GitLab {
    GitLab(...);
    User getUserByEmail(String email);
    ...
}

NOR this level

Socket socket = new Socket(...);
PrintWriter out = new PrintWriter(socket.getOutputStream());
out.println("GET / HTTP/1.0");
...

REST API Middleware

Design “middle” API to simplify writing REST API bindings.

What are the requirements?

Write code that uses your API.

Write the actual API.