When coding, it pays to advance slowly and carefully. We now change our
WordLibraries facade to instead return our ShuffledWordLibrary
that wraps our
old StaticWordLibrary
. We run the code and verify that everything still runs
as before, with the order of the words still the same. We should also run our
unit test to make sure that the words all match.
Note: The facade design pattern makes complex subsystems easier to use. In
Java, we use this pattern a lot, and it is characterized by a class with only
static methods and a private constructor. You will see this in
java.util.Collections
,
java.util.Arrays
, java.util.concurrent.Executors
, etc.
Any class that is written in plural is a likely candidate.
We hope you enjoyed this tutorial. If you did, you will also enjoy our courses. We suggest you start with Extreme Java - Advanced Java, followed by Extreme Java - Concurrency Performance for Java 8.
We deliver relevant courses, by top Java developers to produce more resourceful and efficient programmers within their organisations.
We can help make your Java application run faster and trouble-shoot concurrency and performance bugs...