Can I call a class that does only one controller record?

0

I have a class from an android application that does only the user registry and called it the UserController. In my view controller makes the communication between view and model, but as the class only makes a registration, I believe that it could also be a DAO. I still have a hard time understanding what's in a controller and a DAO

package com.app.eventos.controllers;
import com.app.eventos.dao.ConfiguracaoFirebase;
import com.app.eventos.dao.ConfiguracaoFirebaseAuth;
import com.app.eventos.model.Usuario;
import com.google.firebase.auth.FirebaseUser;

public class UsuarioController {
    private Usuario usuario;

    public UsuarioController() {}

    public void cadastrarUsuario(String nome, String email
    , String senha, String idUser) {
        usuario = new Usuario(nome, email, senha);

        ConfiguracaoFirebase.getDatabaseReference()
        .child("usuarios").child(idUser).setValue(usuario);
    }
}
    
asked by anonymous 19.07.2018 / 01:29

1 answer

4

The number of operations that a class does not define what it is or its behavior, a class that performs the registration of 5 different objects does not change its behavior because it now registers only 3

The controller, as its name says, controls the application, receives the requests / instructions that the user sends, interprets and returns the result, during the interpretation it can interact with other classes, such as model and DAO

DAO is a class that only has one task, to interact with the database, when used with Firebase, is not very useful (compared to a database that is not a baas ), since the write and read action is just one line

In your case, your controller is also a DAO, since it apparently receives the data sent from the user, interacts with the model and registers in the database

What is MVC (Model, View, Controller)?

    
19.07.2018 / 02:26