Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marciojrtorres/6161157 to your computer and use it in GitHub Desktop.
Save marciojrtorres/6161157 to your computer and use it in GitHub Desktop.
Métodos pequenos e com responsabilidade bem definida
class PedidoService {
public Pedido fazPedido(Carrinho carrinho) {
// ... instruções iniciais
if (carrinho.getFormaPagamento() == CARTAO_CREDITO) {
checaCreditoCliente(carrinho.getCliente());
}
// ... mais instruções
}
private void checaCreditoCliente(Cliente cliente) {
SegurCredWS sc = new SegurCredWS();
sc.checaCredito(cliente.getCPF());
if (!sc.getSituacao().equals(Situacao.OK)) {
throw new NoCreditException("Cliente não tem crédito liberado");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment