Assignment 2 – From interfaces to components
1 The back-end service
2 The front-end service

Assignment 2 – From interfaces to components

Due Tuesday 10/8 11:59pm

1 The back-end service

Implement a component that provides a single operation called sort that consumes a list of 10 special JSON objects and returns its argument list in ascending order. In the context of this interface:
  • A special JSON object is either a number or a string or a JSON object with a single field called "name" with a value that is a special JSON object;

  • A special JSON object x is greater than a special JSON object y iff
    • x and y are both numbers and x is greater than y;

    • x and y are both strings and x is lexicographically greater than y;

    • x and y are both objects and the value of x’s "name" field is greater than that of y;

    • x is a string or an object and y is a number;

    • x is an object and y is a string.

Together with the component, you should also implement a test driver, that is a program that simulates a sufficient part of the environment of a component so that we can unit test the component. In this particular case, your test driver should read 10 special JSON objects from STDIN, pass them to the back-end service, and display the result in STDOUT as an array of 10 JSON objects.

Deliverables: In your team’s dev GitHub repository, create a directory "Deliverables/2/2.1/" and deposit there a Makefile for your test driver for the back-end service. In your team’s testing GitHub repository, create a directory "2/2.1/" and deposit there five input files for the test driver and their expected output files. Of course, to do testing correctly, you should create the output files without running the test driver. Name the input files "input1", "input2", etc. and the corresponding output files "output1", "output2", etc.

2 The front-end service

Implement a component that reads special JSON objects from STDIN (as described in task 1) and once STDIN is closed, uses the back-end component to sort them and output the result to STDOUT as described in task 3 of assignment 1.

Deliverables: In your team’s dev GitHub repository, create a directory "Deliverables/2/2.2/" and deposit there a Makefile for your front-end service. In your team’s testing GitHub repository, create a directory "2/2.2/" and deposit there five input files for the front-end service and their expected output files. Name the input files "input1", "input2", etc. and the corresponding output files "output1", "output2", etc.