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

apache - setting document root in antoher partition on ubuntu -

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

Process 'command 'F:\android-sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1 -