Assignment 2 – A couple of simple components
1 The back-end service
2 The front-end service

Assignment 2 – A couple of simple components

Due Wednesday 4/6 5:00pm for the testing deliverables and Friday 4/8 11:59pm for the code deliverables

For this assignment, you must implement both tasks twice, once in the language you chose in the essay you wrote for assignment 1 and once in a different language. Expect to be asked to compare the experience in the two languages if you are chosen for a codewalk.

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 sorts them in ascending order based on the numerical value of their content member.

The grammar below describes the shapes of the JSON that your program must accept. There are two different categories of text in the following grammar. Text that is in a blue fixed-width font is literal text that must appear (using the whitespace rules given in the JSON specification). Text that is in boldface roman text is a non-terminal and refers to another part of the specification (so it is not literal but you must look at its definition to know what should appear). The vertical bars indicate alternatives, meaning that you should choose exactly one of those (any of them is fine) for each use of a non-terminal in bold. For example, where you see value you can replace it with a natural number between one and twenty four.

Note that when you see an object with a specific set of keys, then the objects that match that must have the exact same set of keys. No additional keys and no keys missing. Also, the entire JSON object must match. A matching JSON object that is embedded somewhere inside a larger JSON value does not count.

special-object

 ::= 

{ "content" : value }

value

 ::= 

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12

 | 

13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24

Together with the sorting component, you should also implement a test driver, i.e., 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 a JSON array of 10 objects.

Testing Deliverables: In your team’s GitHub repository, create a directory “Deliverables/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 before writing any code.

Each input file must start with “input” with some more characters (lowercase roman letters digits, underscore or hyphens) and then be followed by “.json”, e.g., “input1.json”, or “input-elephant.json”. Each input file must be matched by a file with the same name name, except the word “input” must be replaced with “output”.

You will receive up to five points for your tests, one point for each valid pair of input and output files.

Code Deliverables: In your team’s GitHub repository, in the same “Deliverables/2/2.1/” directory, add either a script named run that runs the test driver of your back-end service or a Makefile that produces an executable run for the test driver. (If your program can be run via a shell script, it is okay to just push the shell script, but you must have a Makefile, even if it does nothing.)

In addition, in the directory “Deliverables/2/2.2/”, put the implementation of the same component, but in a different language; it should also contain a Makefile that produces run.

You will receive up to twenty-five points for each of your back-end service depending on how many tests the test driver passes.

2 The front-end service

Implement a component that reads JSON values from STDIN and, once STDIN is closed,
  • filters out all but the special-object JSON objects (from the grammar above);

  • splits those JSON values that remain after filtering in groups of 10 respecting the order they were provided through STDIN (leftover objects that do not make a full group are discarded);

  • uses the back-end component to sort each group and;

  • outputs each sorted groups to STDOUT as a single JSON array (that contains JSON arrays with 10 objects each). The result must respecting the order the groups were provided on STDIN.

Testing Deliverables: In your team’s GitHub repository, create a directory “Deliverables/2/2.3/” and deposit there at least five input files for the front-end service and their expected output files.

The input and output filenames must follow the same naming conventions as in 2.1.

You will receive up to five points for your tests, one point for each valid pair of input and output files.

Code Deliverables: In your team’s GitHub repository, in the directory “Deliverables/2/2.3/” add a Makefile that will install any needed dependencies and produces an executable run for your front-end service. This program must be written in the langauge that you chose in your essay from assignment 1.

Implement the same task in the same second language as the back end component and put it in the directory “Deliverables/2/2.4/”, which must also contain a Makefile that will install any needed dependencies and produces an executable run for your front-end service.

You will receive up to twenty-five points for each of your front-end service depending on how many tests each one passes.