Skip to main content

Strategy Pattern

Metadata
Lecture equivalentDuration
32h 15min

At the end of this task, students

  • have studied other design patterns
  • have analysed and described how the strategy pattern works
  • have analysed and described how unit tests isolate the implemented strategy

Finish the bite

Task

Finish the tasks from the lecture:

Refresh git

In the lecture we have seen, that some are shaky on the git-legs.

Optional task

Complete our classroom exercise Git & GitHub Fundamentals. It is a basic onboarding course to git. You do not need to hand in any result here, the classroom of GitHub handles that for you ๐Ÿ‘๐Ÿผ

Digest

We mentioned it already some times, a key soft skill of an engineer is to understand code from others. The engineer before you (me ๐Ÿ˜ˆ) was an ๐Ÿ•ณ, he did not leave any comments in code. But he is convinced that he did a great job at implementing the strategy pattern! He even wrote tests ๐Ÿš€

Task

You will be given a list of classes. Open up these classes and document inline what the author did implement!

How to

Lets take a look at this line.

Logger logger = LoggerFactory.getLogger(SortingFactory.class);

Annotate it for example like so:

Logger logger = LoggerFactory.getLogger(SortingFactory.class); // Request a new logger that will log with the prefix 'SortingFactory: <log message>'

You can also use block comments:

/** 
* Request a new logger that will log with the prefix 'SortingFactory: <log message>'
*/
Logger logger = LoggerFactory.getLogger(SortingFactory.class);

Do that for every line you consider worth commenting. You might need to google what some lines do, but that is also a key skill.

Start

You know how git works. I do not tell you how.

Result

Hand in a commit sha to the assignment where I can see your comments!

Work

Checkout this release.

Comment the following classes:

โ””โ”€โ”€ src
โ”œโ”€โ”€ main
โ”‚ย ย  โ””โ”€โ”€ java
โ”‚ย ย  ย ย  โ””โ”€โ”€ ch
โ”‚ย ย  ย ย  โ””โ”€โ”€ abbts
โ”‚ย ย  ย ย  โ””โ”€โ”€ nds
โ”‚ย ย  ย ย  โ””โ”€โ”€ swe
โ”‚ย ย  ย ย  โ””โ”€โ”€ swdt
โ”‚ย ย  ย ย  โ””โ”€โ”€ starter
โ”‚ย ย  ย ย  โ””โ”€โ”€ skill
โ”‚ย ย  ย ย  ย ย  โ”œโ”€โ”€ AscendingStringOrderImpl.java
โ”‚ย ย  ย ย  ย ย  โ”œโ”€โ”€ SkillsController.java
โ”‚ย ย  ย ย  ย ย  โ”œโ”€โ”€ SkillsRepository.java
โ”‚ย ย  ย ย  ย ย  โ”œโ”€โ”€ SkillsService.java
โ”‚ย ย  ย ย  ย ย  โ””โ”€โ”€ SortingFactory.java
โ””โ”€โ”€ test
โ””โ”€โ”€ java
โ””โ”€โ”€ ch
โ””โ”€โ”€ abbts
โ””โ”€โ”€ nds
โ””โ”€โ”€ swe
โ””โ”€โ”€ swdt
โ””โ”€โ”€ starter
โ””โ”€โ”€ skill
โ”œโ”€โ”€ SkillControllerTestIT.java
โ””โ”€โ”€ SkillServiceTest.java

In total you must comment 7 classes.

Reminder

In order to check this into your repository you need to delete my .git folder, then use git init to create a new working copy (remember the whiteboard drawing from the lecture).