The design decisions you make affect not only how well you can maintain your code but also how well others can use your code. Multithreading adds a new dimension to your designs and I’ll give you some of my thoughts in this episode.
The example class used in this episode is called TotalsTen and consists of three properties:
left -> an integer property value that can be read and written.
right -> an integer property value that can be read and written.
perfectScore -> a bool property value that can be read.
The idea behind this class is that the perfectScore property will be true only when the left and right values add up to the value ten.
This class sets us up for a race condition and makes it difficult to fix due to the design. I explain how to improve this design while still keeping the original purpose of the class intact.