Difference between List and and Return in Entity

2

Hello, I have a question when I get the data of a SQL query, there is the possibility of pulling by list and by Entity, what would be the "most correct" or usability of each?

public List<Usuario> buscarTodos(Usuario mod){...}

public Usuario pesquisarUsuario(Usuario mod) {...}
    
asked by anonymous 02.08.2016 / 20:58

1 answer

1

Considering good practice, I believe the first method is confusing and does not apply. Since you are passing a User parameter to listAll users, I would use this:

public List<Usuario> buscarTodos(){...}

The second method has more meaning, and by itself is already self explanatory, ie, just looking at the signature is already understood for what it serves.

public List<Usuario> pesquisarUsuario(Usuario mod){...}
    
02.08.2016 / 21:17