"Hi, Amigo!" I came up with a couple of interesting tasks for you."
"They can only be completed in IntelliJ IDEA. Take a look at these interesting conditions…"
14
Task
Java Collections,
level 1,
lesson 8
Locked
Null object pattern
Read about the null-object pattern on Wikipedia.
Use Files to correctly initialize the fileData field with a ConcreteFileData object in the Solution class's constructor.
If you have any problems reading the file in the pathToFile path, then initialize the field with a NullFileData object.
7
Task
Java Collections,
level 1,
lesson 8
Locked
Path 101
Read about all of the Path class's methods.
Find one that creates a relative path between the current path and a passed path.
Implement the getDiffBetweenTwoPaths method. It must return a relative path.
The main method is not tested.
For those interested, the idea behind the null object pattern is this. When I'm writing normal code with normal (non-null) objects, I should create something like a sibling class of my class, which will inherit the same interface as my class does and provide empty implementations of the methods that my class implements normally. If someone got a better understanding, please share:).
I think that course could be so much better if each level starts with many simple tasks like that, teaching simple concepts and on the end each level tasks like that from previous page.
Justin SmithLevel 41, Greenfield, USA, United States
10 August 2022
Both of these were quite a bit easier than some of the other recent tasks. Kind of a relief!
GO TO FULL VERSION