There are situations in which we have fields that represent a type of response, whether they are boolean sim
and não
, S
and N
or with multiple answers like the status of something. For example the status of a course certificate analysis provided by an institution:
S
N
A
Considering the above context, the use of constant can be adopted to make it easier to read the code.
Now see a real example of the Instituicao
class that has answer-type fields in which you are using constants for them:
public class Instituicao
{
public static string DeletadoSim { get; } = "S";
public static string DeletadoNao { get; } = "N";
public static string AtivaSim { get; } = "S";
public static string AtivaNao { get; } = "N";
public static string CertificadoDisponivel { get; } = "S";
public static string CertificadoNaoDisponivel { get; } = "N";
public static string CertificadoEmAnalise { get; } = "A";
public int Id { get; set; }
public string RazaoSocial { get; set; }
public string UrlSite { get; set; }
public string Ativa { get; set; } = AtivaSim;
public string TemCertificadoGratuito { get; set; }
public string Deletado { get; set; } = DeletadoNao;
public DateTime DataCadastro { get; set; }
public List<Curso> Cursos { get; set; }
}
So, the scenario that was illustrated above left me with doubts regarding the naming and creation of constants.