Skip to main content
Post Closed as "Duplicate" by gnat, user53019, Bart van Ingen Schenau, Dan Pichelman, user40980
'i' capitalized. First word of sentence capitalized.
Source Link
user40980
user40980

How could iI avoid singletons in this case?

usingUsing Dart in the client part of a web app where iI have an application manager that contains a ListList of application instances and references to services that are used by each application as in the following diagram

enter image description herediagram

asAs you can see the application manager is a singleton, so are the services that it contains which are used by all apps, to me it makes sense because

  • iI need to have only one instance of the ApplicationManager and each service
  • easierEasier to access services without the need to pass references
  • iI need to preserve the state of each service
  • almostAlmost all services have a cache

iI found ways to avoid having the services as singletons which is by making them private to the library which is a feature in dart, so iI initialize the services only once from the application manager, but iI can't make the ApplicationsManager private because its at the top most level of the library, iI would appreciate your thoughts for a way to avoid having the application manager as a singelton.

How could i avoid singletons in this case?

using Dart in the client part of a web app where i have an application manager that contains a List of application instances and references to services that are used by each application as in the following diagram

enter image description here

as you can see the application manager is a singleton, so are the services that it contains which are used by all apps, to me it makes sense because

  • i need to have only one instance of the ApplicationManager and each service
  • easier to access services without the need to pass references
  • i need to preserve the state of each service
  • almost all services have a cache

i found ways to avoid having the services as singletons which is by making them private to the library which is a feature in dart, so i initialize the services only once from the application manager, but i can't make the ApplicationsManager private because its at the top most level of the library, i would appreciate your thoughts for a way to avoid having the application manager as a singelton

How could I avoid singletons in this case?

Using Dart in the client part of a web app where I have an application manager that contains a List of application instances and references to services that are used by each application as in the following diagram

diagram

As you can see the application manager is a singleton, so are the services that it contains which are used by all apps, to me it makes sense because

  • I need to have only one instance of the ApplicationManager and each service
  • Easier to access services without the need to pass references
  • I need to preserve the state of each service
  • Almost all services have a cache

I found ways to avoid having the services as singletons which is by making them private to the library which is a feature in dart, so I initialize the services only once from the application manager, but I can't make the ApplicationsManager private because its at the top most level of the library, I would appreciate your thoughts for a way to avoid having the application manager as a singelton.

deleted 100 characters in body
Source Link

using Dart in the client part of a web app where i have an application manager that contains a List of application instances and references to services that are used by each application as in the following diagram

enter image description here

as you can see the application manager is a singleton, so are the services that it contains which are used by all apps, to me it makes sense because

  • i need to have only one instance of the ApplicationManager and each service
  • easier to access services without the need to pass references
  • i need to preserve the state of each service
  • almost all services have a cache

i found ways to avoid having the services as singletons which is by making them private to the library which is a feature in dart, so i initialize the services only once from the application manager, but i can't make the ApplicationsManager private because its at the top most level of the library, i would appreciate your thoughts for a way to avoid having the application manager as a singelton

how about a static boolean field that gets checked in the constructor of ApplicationManager class?

using Dart in the client part of a web app where i have an application manager that contains a List of application instances and references to services that are used by each application as in the following diagram

enter image description here

as you can see the application manager is a singleton, so are the services that it contains which are used by all apps, to me it makes sense because

  • i need to have only one instance of the ApplicationManager and each service
  • easier to access services without the need to pass references
  • i need to preserve the state of each service
  • almost all services have a cache

i found ways to avoid having the services as singletons which is by making them private to the library which is a feature in dart, so i initialize the services only once from the application manager, but i can't make the ApplicationsManager private because its at the top most level of the library, i would appreciate your thoughts for a way to avoid having the application manager as a singelton

how about a static boolean field that gets checked in the constructor of ApplicationManager class?

using Dart in the client part of a web app where i have an application manager that contains a List of application instances and references to services that are used by each application as in the following diagram

enter image description here

as you can see the application manager is a singleton, so are the services that it contains which are used by all apps, to me it makes sense because

  • i need to have only one instance of the ApplicationManager and each service
  • easier to access services without the need to pass references
  • i need to preserve the state of each service
  • almost all services have a cache

i found ways to avoid having the services as singletons which is by making them private to the library which is a feature in dart, so i initialize the services only once from the application manager, but i can't make the ApplicationsManager private because its at the top most level of the library, i would appreciate your thoughts for a way to avoid having the application manager as a singelton

Source Link

How could i avoid singletons in this case?

using Dart in the client part of a web app where i have an application manager that contains a List of application instances and references to services that are used by each application as in the following diagram

enter image description here

as you can see the application manager is a singleton, so are the services that it contains which are used by all apps, to me it makes sense because

  • i need to have only one instance of the ApplicationManager and each service
  • easier to access services without the need to pass references
  • i need to preserve the state of each service
  • almost all services have a cache

i found ways to avoid having the services as singletons which is by making them private to the library which is a feature in dart, so i initialize the services only once from the application manager, but i can't make the ApplicationsManager private because its at the top most level of the library, i would appreciate your thoughts for a way to avoid having the application manager as a singelton

how about a static boolean field that gets checked in the constructor of ApplicationManager class?