After a few years I'm trying to get back to programming and therefore i am trying to programm a relatively simple app in android studio.
Im still at the part of thinking how the programm should be lazed out, where to place which attributes and methods. Since i would like to programm this app neatly. Its supposed to be an App which can log parameters of a specific event. For this event (sudden change of the devices orientation), I will create a class in which the data (e.g. duration, angle...) is stored.
I obviously need some sort of Listener that is checking if the event is happening. Where do I locate this method/listener?
Here are my thoughts about this:
Should it be a method of the class of this event? This seems to make sense until I have to implement it. To call this method I would have to create an instance of this object an than call the Listener. Once the event has happened I would save this instance to the database. This seems kind of odd to me.
On the other hand i could create the function/method somewhere else and only create an an instance of the event once the event is happening. Would the listener be a class for its own, of which I create an Instance once the tracking is activated?
If there is a (short) document regarding these basics im happy to read that. But since i#m still doing this for fun, i#m noot looking for a 400 page book about OOP. I appreciate any helpful comment regarding this topic!
I tried to sketch the most needed basic structure of the JavaScript implementation which did answer following SO question ... "How to implement an event dispatching system for ES/JS object types?"