The whole example of the singlet chocolate ice cream really bothered me when I read it.
At a truly fundamental level, I don’t understand why this is necessary when you have only one physical thing to ensure this fact in the software. What happens if you get another one? what are you going to do, add the second to the same singleton? make 2 different singleton? a simple global variable would do the job.
IMO, this is not the boiler itself, from which you can have only one, its access to this particular boiler controller. You cannot allow the second person to start making a new batch of chocolate while he is already in the process for someone else, or even let the same person make the second batch before the first is finished. From this point of view, a simple queuing or batch processing system would do the job. Using another sample from the book, the team template will be a much better way of processing, as there is only one waitress, and all new orders will be queued until the cook makes a meal with the current order. (er, if you have not seen the book, what I just said may not make sense, sorry)
Maybe I just don't get it. Because of this, I did not do a lot of OOP or anything with design templates, and I lose the opportunity to work, so I read about it.
pizza
source share