P
Phl
hi,
just wondering which way of coding is considered better?
This style where the two returns aren't interconnected by an else
statement in the if seems to be very popular these day, where use ch:
public static bool IsProfileLoaded()
{
EditProfile ep = (EditProfile)BLL.TicketContext.Instance.GetUserControl("EditProfile");
if(ep == null)
{
return false;
}
//no else statement here
//does this generate less code as a result
//it's less obvious
return true;
}
This is what C programmers used to do:
public static bool IsProfileLoaded()
{
EditProfile ep = (EditProfile)BLL.TicketContext.Instance.GetUserControl("EditProfile");
if(ep == null)
{
return false;
}
else //this make it clearer it seems
{
return true;
}
}
Which is better?
cheers
just wondering which way of coding is considered better?
This style where the two returns aren't interconnected by an else
statement in the if seems to be very popular these day, where use ch:
public static bool IsProfileLoaded()
{
EditProfile ep = (EditProfile)BLL.TicketContext.Instance.GetUserControl("EditProfile");
if(ep == null)
{
return false;
}
//no else statement here
//does this generate less code as a result
//it's less obvious
return true;
}
This is what C programmers used to do:
public static bool IsProfileLoaded()
{
EditProfile ep = (EditProfile)BLL.TicketContext.Instance.GetUserControl("EditProfile");
if(ep == null)
{
return false;
}
else //this make it clearer it seems
{
return true;
}
}
Which is better?
cheers