According to SOLID, Single Responsibility Principle says, It is of sole responsibility and says that each class must deal with only one task and that applies to its methods. I have a Save method which updates a record and also saves a record, it has two responsibilities.
if (HelpAccesoDatos.Existe)) {
try {
ClienteRepository.Actualizar(cliente);
MensajeLogica = "REGISTRO ACTUALIZADO!!!";
} catch (Exception) {
MensajeError = "No se puedo actualizar el registro";
}
} else {
try {
ClienteRepository.Guardar(cliente);
MensajeLogica = "REGISTRO GUARDADO!!!";
} catch (Exception) {
MensajeError = "No se pudo guardar el registro";
}
}
Should I separate this method in two? Is it a bad programming practice? From my point of view I feel comfortable with this method both for code maintenance and implementation. I thank you in advance for your recommendations.