Design Pattern: Singleton (Creational)

버전 1.2.0.1 (39.8 KB) 작성자: Rob Purser
A MATLAB® OOP implementation of the Singleton Creational Design Pattern
다운로드 수: 3.6K
업데이트 날짜: 2016/9/1

라이선스 보기

Intent: Ensures a class only has one instance and provide a global point of access to it [1].
Motivation: It's important for some classes to have exactly one instance. For example, it can be desirable to have only a single instance of a GUI. With a MATLAB® GUIDE built GUI, the driver or main function provides a global point of access which is executed to,
1. initially instantiate the GUI; and
2. subsequently bring the existing GUI into focus *not* creating a new one.

Refer to the comments in 'Singleton.m' and 'SingletonImpl.m' for detail on the implementation. The script 'testSingletonImpl.m' demonstrates the use of 'SingletonImpl.m'. Further, a corresponding UML class diagram is illustrated in 'Singleton_UML_Diagram.pdf'.

Refer to pp.127-134 Gamma et al.[1] for more information on the Singleton Design Pattern.

Written by Bobby Nedelkovski
The MathWorks Australia Pty Ltd
Copyright 2009, The MathWorks, Inc.

Reference:
[1] Gamma, E., Helm, R., Johnson, R. and Vlissides, J. Design Patterns : Elements of Reusable Object-Oriented Software. Boston: Addison-Wesley, 1995.

인용 양식

Rob Purser (2024). Design Pattern: Singleton (Creational) (https://www.mathworks.com/matlabcentral/fileexchange/24911-design-pattern-singleton-creational), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2009a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Software Development Tools에 대해 자세히 알아보기
도움

도움 준 파일: Matlab logging facility

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.2.0.1

Updated license

1.2.0.0

Updated UML diagram to reflect inheritence from 'handle' class and usage of persistent variable 'uniqueInstance' in concrete class 'SingletonImpl'. Also MathWorks registered trademarks added to files.

1.0.0.0