static class 를 사용하려 하다 문득 singleton과의 차이점이 궁금하여 찾아보았다. 아래 4가지가 내가 여러 포스트에서 본 것을 정리해둔 것 같다.
- Singleton objects are stored in Heap, but static objects are stored in stack.
- We can clone (if the designer did not disallow it) the singleton object, but we can not clone the static class object .
- Singleton classes follow the OOP (object oriented principles), static classes do not.
- We can implement an
interface
with a Singleton class, but a class’s static methods (or e.g. a C#static class
) cannot.
https://stackoverflow.com/questions/519520/difference-between-static-class-and-singleton-pattern
참고해볼 다른 포스트
https://postpiglet.netlify.app/posts/csharp-singletone-vs-staticclass/