Home>
Assumptions

I am currently making a mobile application using firebase, but I have no experience of object-oriented development, so I'm wondering how to design a class.

My app has User data and I want to store it locally on the firebase side.
For now, I create a User class and write all of firebase and local reading and writing in it.
I don't know much about it, but I've heard that in object orientation, classes are divided into roles. In the case of my application, the User class only has User data, and I think that the processing that handles DB should create another class.

However, I don't know exactly what kind of class it should be.
How do you design a class in such cases?

If i have a good book to learn about designing a class like this, please let me know.
Thank you in advance.

The language uses C #.

  • Answer # 1

    First, create an abstract class to save and load data.
    This class has two methods as abstract methods: save method and load method.

    Create a class that derives from it and saves/loads to/from Firebase and a class that saves/reads from/to files.
    Both of these classes are derived from the first class you created, so you can save and load them using the same procedure.

    User classes are independent of these.

    If another storage location is added or Firebase is switched to another database, it will be derived from the first class as well.