SWEA 2025 Weekplan 12

The learning goals for Week 47 are:

Mon: Broker II Mandatory Intro. Wed: HTTP. Web frameworks. URI Tunneling. REST.

Literature:

Slides:

Notes for this weekplan:

The Monday lecture starts at 9.15 and provides hints on the last mandatory exercises / Iteration 10. The Wednesday lectures is about cursory (but in practical engineering important) material about HTTP and Web frameworks. The REST presentation is screencast only.

Lab classes this week is focused on the Iteration 9 Broker exercises; and you may optionally spend time on the URI Tunnel and REST exercises below.

The 'HelloJavalin.java' can be found in hello-javalin.zip.

The 'ShowUniRest.java' can be found in showunirest.zip.

Kata

Spend the first 15-20 minutes of the TØ/Lab class in plenum discussing...

... depth-first TDD of ClientProxy and Invoker code

To make any of Game's methods work in a distributed setting, implementation effort is required on both the client side (ClientProxy) and on the server side (Invoker).

Consider more concretely the Game method

int getFieldSize(Player who);          
        

To implement that, you need to implement two pieces of code. First, the GameClientProxy's method body must be coded

  @Override
  public int getFieldSize(Player who) {
    Integer fieldSize = 
       // use requestor's sendRequestAndAwaitReply to call server
    return fieldSize;
  }
        

And next, the GameInvoker's handleRequest method must have an if-branch that handles that method

  } else if (operationName.equals(OperationNames.GAME_GET_FIELD_SIZE)) {
    int value = // upcall to proper method on proper servant object
    reply = new ReplyObject(HttpServletResponse.SC_OK, gson.toJson(value));
  } else if (....)   
        

As there are two pieces of code to be developed, the TDD Take Small Steps... value would point us towards making two iterations/test cases: one for driving the ClientProxy code into place; and next a second one for driving the Invoker code into place.

  1. Sketch code for a test case to TDD the ClientProxy implementation only. How will you validate that your code is correct (which assertThat statements)? Hint: You need test doubles.
  2. Similar, sketch code and assertThats for a test case to TDD the Invoker's getFieldSize() handling.
I call this a 'breath-first' approach - as you can develop the breath of all ClientProxy methods before you start on the Invoker code.

  1. Next, outline the recommended depth-first approach - in which you use manual inspection of print output in the LocalMethodClientRequestHandler to get first ClientProxy and next Invoker code in place - but in a single test case. Hint: Study my slides W11-1.
  2. Argue for the benefits and liabilities of each approach? Why is the depth-first approach my recommendation?
I call this a 'depth-first' approach - as you develop 'deep'/all aspects of one method, before going to the next.

Optional Exercises:

These are optional exercises. Be sure to solve the mandatory project first, and only if you have a lot of spare time, try having a look at the exercises below.

TeleMed URI Tunneling

Redo last weeks using the TeleMed system, but instead use the HTTP variant (targets 'serverHttp' and 'homeHttp').

PasteBin

Extend the PasteBin server so it also supports Update and Delete (PUT and DELETE verbs).

You can find the pastebin project as a subproject in the FRDS.Broker code base.

Coffee Shop

Solve the REST Level 2 exercise described in W12-7 REST Exercise.

The source code for the coffeeshop exercise can be found in coffeeshop.zip.