Created
August 6, 2013 01:06
-
-
Save marciojrtorres/6161157 to your computer and use it in GitHub Desktop.
Métodos pequenos e com responsabilidade bem definida
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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