Can I call a class that only does a controller’s record?

Asked

Viewed 99 times

0

I have a class of an android application that does only user registration and I called it Usuariocontroller. According to my controller, it communicates between view and model, but since the class only makes a register, I think it could also be a DAO. I still have a hard time understanding what’s in a controller and 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);
    }
}
  • 1

    Juliana, could you edit your question and instead of pasting an image, put the class in text format? Over time, if the image link expires, your question will lose its meaning and make it difficult for others who have the same doubt as yours ;)

1 answer

3


The amount of operations a class performs does not define what it is or its behavior, a class that registers 5 different objects does not change its behavior because now only registers 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 has only one task, interact with the database, when used with Firebase, is not very useful (compared to a database that is not a Baas), since the action of writing and reading is only 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)?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.