1
I have a form that will store the employee’s medical records in a database. The problem is that this form has more than 30 fields. I am using POO to register this way:
$metodos->cadastrarFichaMedica($idFuncionario,$tipoSanguineo,$planoSaude,$calendarioVacinal,$nomeContatoI,$telefoneFixoI,$nomeContatoII,$telefoneFixoII,$nomeContatoIII,$telefoneFixoIII,$viveCom,$doencasTeve,$alergias,$qualOutrosAlergia,$atrasoDesenvolvimento,$qualOutrosAtraso,$pcd,$problemasCoracao,$qualProblemaCoracao,$acompanhamentoProblemasCoracao,$qualAcompanhamentoProblemaCoracao,$alergiaMedicamento,$qualAlergiaMedicamento,$intoleranciaGluten,$qualIntoleranciaGluten,$tomaMedicamento,$cirurgia,$ficouInternado,$problemasPeso,$qualTratamentoEspecializado,$qualTratamentoEspecializado,$observacoes);
Class page:
public function cadastrarFichaMedica($idFuncionario,$tipoSanguineo,$planoSaude,$calendarioVacinal,$nomeContatoI,$telefoneFixoI,$nomeContatoII,$telefoneFixoII,$nomeContatoIII,$telefoneFixoIII,$viveCom,$doencasTeve,$alergias,$qualOutrosAlergia,$atrasoDesenvolvimento,$qualOutrosAtraso,$pcd,$problemasCoracao,$qualProblemaCoracao,$acompanhamentoProblemasCoracao,$qualAcompanhamentoProblemaCoracao,$alergiaMedicamento,$qualAlergiaMedicamento,$intoleranciaGluten,$qualIntoleranciaGluten,$tomaMedicamento,$cirurgia,$ficouInternado,$problemasPeso,$qualTratamentoEspecializado,$qualTratamentoEspecializado,$observacoes){
// Faço o cadastro
}
The problem is it’s gotten too big and I’d like to know how I can fix it? My idea was to divide into two or more parts, but as I could do within the good programming habits?
Break in lines. PHP doesn’t have to have everything in one line. It’s a good habit to know how to program only. The best habit is not to use POO in PHP, because it is a waste of resources - think to me, the objects serve to keep state, and PHP does not. And if it is to use POO, it is useless to mix everything in the class. This is not POO, it is a disguised function (Phpeiro does it a lot). Make everything cute with functions, it gets better. When you have a domain name, you can use POO (but when you have a real domain name, you’ll see that it’s best not to use it in PHP. You can see that only crap comes out in POO with PHP practically)
– Bacco