Skip to content

Instantly share code, notes, and snippets.

@marciojrtorres
Last active December 20, 2015 16:28
Show Gist options
  • Save marciojrtorres/6161173 to your computer and use it in GitHub Desktop.
Save marciojrtorres/6161173 to your computer and use it in GitHub Desktop.
Parâmetros demais == "malz"
class ImovelDAO {
List<Imovel> busca (Integer nroQuartos, Integer nroVagasCarro,
Double vlrMaximoCondominio, Double vlrMaximoAluguel,
Boolean comFoto, Boolean apartamento) {
// ... código necessário para fazer a busca
}
}
// uma chamada seria assim:
ImovelDAO dao = new ImovelDAO();
// o que seriam "2, 2, 800, 500, false, true" sem olhar a assinatura no método?
List<Imovel> imoveis = dao.busca(2, 2, 800, 500, false, true);
class ImovelDAO {
List<Imovel> busca (FiltroImovel filtro) { // só um parâmetro!
// ... código necessário para fazer a busca
}
}
// classe,objeto parâmetro
class FiltroImovel {
public Integer nroQuartos, nroVagasCarro;
public Double vlrMaximoCondominio, vlrMaximoAluguel;
public Boolean comFoto, apartamento;
}
// uma chamada seria assim:
ImovelDAO dao = new ImovelDAO();
FiltroImovel filtro = new FiltroImovel() {{
vlrMaximoAluguel = 500;
nroQuartos = 2;
vlrMaximoCondominio = 800;
apartamento = true;
comFoto = false;
nroVagasCarro = 2;
}};
List<Imovel> imoveis = dao.busca(filtro);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment