Skip to content

Singleton

Thomas Schwotzer edited this page Aug 27, 2021 · 3 revisions

You a familiar with the singleton pattern. It should be handled with care. It has the tendency to shift an object oriented program into a mess similar to good old C programs.

It has its advantages, though. Take this section as thoughts and a rule of thumb but not as strong rule. You follow your way.

You have to implement a GUI for your application logic. GUI code is split into two major parts: Layouts, menus etc. are defined in resources. Activities glue user actions and application logic together.

You activities will always need access to your components. How to get them?

singleton

Singleton pattern seams useful in this scenario. We defined a class SharkNetApp. This class represents the whole Android application.

It provides a initializeSharkNetApp method.

Clone this wiki locally