I have many parameters for the marker (s) such as title, subtitle, snipper, tags, position. + I have these markers in many fragments. Is it worth it / is it right to put these parameters into the model (if yes, then how to apply to them correctly)?

PS In the future I plan to transfer them to the Firebase database.

  • one
    Well, of course, why not? You will store them in the database. And the table - already the relational model will remain only an object to tie! - JVic

1 answer 1

Well, as long as you understand it, there is no storage and you just want to model the classes between classes. Here, in principle, you can simply apply directly, but when the base is already there, I would create some class on top of this base in order to unify all the calls to the base and forward them through this class. That then it was easier to change the base.

Let me explain, let's say you have a class SomeDatabase and a method in getAllMarkersFromDB (), you are on top of the class that works with the database, you are sawing another class, call it valid MarkersRepository and add the method getAllMarkers () to it, and in this method you call SomeDatabase # getAllMarkersFromDB () ). Everywhere in the code you are working with the MarkersRepository class. This is such an encapsulation, if you want to later change the database, then simply rewrite the getAllMarkers () method and you will not need to change anything in the whole project. The description of course is difficult, but in practice it is easier to do.