1
I wonder what kind of class this is DaoDeAutenticacao
, whose skeleton I wrote down. Despite the name I don’t think it’s a DAO (Data Access Object), however it is defined, and yes something else (a Data Mapper?). I’d like to know what name has this pattern, if it has one.
Its intention is not to map a single database table but a set of related tables, although the example is mapping a single one.
The Java object CentralDeAlarme
populated with the database data and returned by the method autenticar()
is an object of interest in the field of application. Moreover, what is called this object? It is a Data Transfer Object (DTO)?
public class DaoDeAutenticacao {
...
public CentralDeAlarme autenticar(String senha) {
CentralDeAlarme resultado = null;
try {
// Abre conexão com o banco
// Monta e chama statement
// SELECT c.id, c.fabricante, c.modelo FROM centrais c WHERE c.senha = senha;
resultado = new CentralDeAlarme(id, fabricante, modelo);
return resultado;
finally {
// fecha conexão com o banco
}
}
}
Using the Datodeauthentication class:
CentralDeAlarme central = daoDeAutenticacao.autenticar(senha);
if (central == null) { // autenticação falhou
...
return;
}
// autenticação bem-sucedida
Logger.log("Central autenticada: " + central);
...
The Centraldealarme class:
public class CentralDeAlarme {
private final int id;
private final Fabricante fabricante;
private final Modelo modelo;
// getters
}
It’s certainly not DTO. Actually I’m not sure I understand the question.
– Maniero
I improved the question, please see if it became clearer.
– Piovezan
The new code appears to be a DTO.
– Maniero
And the
DaoDeAutenticacao
, would be what?– Piovezan
I think it’s weird, but it might just be me who doesn’t know how to do those things that people do around here :)
– Maniero
So it’s not a DAO, it’s just a weird class? P
– Piovezan
I don’t consider it a DAO.
– Maniero
Understood. I will have to research further then to know what is considered a DAO.
– Piovezan