4 ms·
It really depends on the context of what you're trying to do. If you're whipping together something as a test, or if it's code that you _know_ will be thrown aw
by jobu 13y ago
It really depends on the context of what you're trying to do. If you're whipping together something as a test, or if it's code that you _know_ will be thrown away in the future, then cowboy it up and get it done quickly. Good design and quality work takes more time than is needed for many first iterations so YAGNI is right.
The flip side is that if quality does matter for a project, then unit tests are important, and the whole point of Aaronaught's answer is that things like unit tests and refactoring are usually impossible with a traditional singleton pattern.
It's definitely a fine line though. As a wise programmer once said: "Broken gets fixed, but shitty lasts forever." Be careful when you deliberately choose the shitty route - it usually comes back to bite you.