Strategy Pattern
Metadata
Lecture equivalent | Duration |
---|---|
3 | 2h 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:
- Watch 5 Design Patterns Every Engineer Should Know
- Analyse at least three more design patterns over at refactoring.guru/design-patterns/catalog
- Hand the patterns in to the form
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).