M5ez / Core2ez

GNU Lesser General Public License v3.0
15 stars 4 forks source link

Suggestion: Singleton Pattern #6

Open vkichline opened 4 years ago

vkichline commented 4 years ago

There are a number of Singleton classes in Core2ez, but they don't follow the Singleton Pattern, designed for the kind of safety a library to be used by non-experts can benefit from: See: Singleton Pattern or another

While the terms "sloppy" and "naïve" are used to describe the simpler version in the first reference, these are simply synonyms for "single threaded" and are probably completely safe to use in Core2ez; I don't see multi-threading being given special consideration anywhere (in Arduino code in general.)

Using the Pattern is safer (has been industrially tested) and makes the intention of the code clearer.