Skip to content

Conversation

@antheia-z
Copy link

@antheia-z antheia-z commented Aug 16, 2021

The factory and singleton patterns were introduced to the data source to make it easier to modify the code when changes need to be made to the data source and to reduce memory usage.

To do this, I first created a factory called DataSourceFactory, including getInstance and getService methods. After that, I created subclasses of the factory for each of the three data sources. Then, I make the factory a singleton by using the getInstance method, which creates a new object the first time it is called and stores it in a static variable. The method returns the instance each time it is called after that. In addition, I made the Service a singleton by using getService, which is implemented in the same way as getInstance.

@Kilo59 Kilo59 closed this Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants