SWEA 2025 Weekplan 7

The learning goals for Week 41 are:

Mon: (Lectures cancelled). Wed: Design Pattern Catalogue.

Literature:

Slides:

Notes for this weekplan:

Monday lectures are cancelled, as we have amble time Wednesday to cover the central patterns in our design pattern catalogue. (The non-essential patterns (read: not present at the SWEA exam) are covered in listen-in-your-own-pace screencasts.) I will also go over some notes on the mandatory as usual.

Last week before the Autumn break. No lecturing nor lab exercises in week 42.

Kata

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

... Private Interface

Briefly read the FRS's §37.5 about a MutableGame private interface, in order to addresse the following Kata...

... UnitTesting Card Effects

We need to TDD that a card effect like Brown Rice: "Deal 1 damage to opponent hero" works correctly. We can do this either by unit testing the effect or integration testing the effect. Unit testing means "in isolation" while integration testing means "in collaboration".

Thus integration testing the Brown Rice effect would follow a GWT like:

          GIVEN a Game with Peddersen's Hero health equal to 21
          WHEN Findus plays the Brown Rice Card to the field
          THEN Peddersen's hero's health is 20
        
That is - both the card, its effect strategy, the game object, and the hero object are all required to verify correct behaviour. And any defect in any of them, may make the test fail.

However, unit testing the Brown Rice effect would isolate the effect object completely, which would then amount to a GWT like:

          GIVEN the Effect object (instance of the Effect Role interface) for Brown Rice
          WHEN the 'execute(mutableGame)' method is called
          THEN the Test Spy (implementing MutableGame) has recorded that the method
          'changeHeroHealth(who, delta)' has been called with who=Peddersen, and delta=-1.
        
That is, no other object but the effect itself and a spy object is involved.

Sketch code for the unit testing approach:

  1. How does the test method for the above GWT look like?
  2. How does the setup (@BeforeEach) method look like?
  3. How is the Test Spy coded?
  4. Argue why the 'Private Interface' concept is essential to make this unit testing work.

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.

20.4 21.2

Rehearse a pattern exam situation. Spend 20-25 minutes to prepare a 10 minute oral presentation of an exercise in the example exam question set: demo-question-2025.pdf.

Next, do a 10 minute presentation at the whiteboard in front of your team.

The team provides constructive feedback on the presentation: Is your presentation clear and understandable, do you discuss the concepts and terms correctly, is you Java example code correct, etc. Swap and ensure all in the team gets a chance to rehearse the situation.