singleton - Use cases of the Signleton pattern -


i doing test, , confused on below question.

which type of application benefit using singleton pattern?

  • a. application interacts external systems in serial fashion.
  • b. application interacts external systems in parallel fashion.
  • c. clustered application can support 200 concurrent users.
  • d. application requires remote monitoring capabilities

there tests right answer , other tests answer d. correct answer?

what (e) - small project not going heavily tested?

singleton anti-pattern. should not use in system pollutes global state, more complex , less useful. don't want coupled singleton. moreover, using in multi-threaded environment lead disaster. imagine have several tests each changes singleton's instance. imagine tests concurring.

eliminate use of singleton pattern in code-base , start considering better design. suggest taking advantage of dependency inversion principle , using dependency container instead.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -