Are there any downsides to the singleton pattern? [duplicate]
-
23-09-2019 - |
문제
Possible Duplicates:
What is so bad about Singletons
Problems with Singleton Pattern
Are there any downsides to the singleton pattern? I heard this was an interview question and i am coming up short on what was meant.
imho, it's about the usage and nothing in the pattern itself is problematic
해결책
From Wikipedia:
Some consider it an anti-pattern, judging that it is overused, introduces unnecessary limitations in situations where a sole instance of a class is not actually required, and introduces global state into an application.
Personally, since I've started using Spring to auto-wire my application I've never had the need to write a singleton.
다른 팁
최저치를 설정하면 Parsefloat를 시도하십시오.
var minimumPercent = ParseFloat($('.donationTextBox').val());
.
엔진이 문자열을 플로트로 비교하면서 Float을 문자열로 변환하고 100.00 <2.50= true 왼쪽에서 오른쪽 알파벳순 비교로 true를 변경합니다.
마이크
- Not testable or at least it's difficult
- Hard to find dependent classes
- Does not allow subclassing
- ...