Alternative way to write conditional statement

elfatehonline

New Member
Here I have a sample of code.I would like to know other way to write this code; specially I would like to know other forms for the nested \[code\]if\[/code\].Also I would like your opinion about commenting (what are the best practice, is my style of commenting sufficient in professional environment?)If this question is out of scope for SO please let me know, I will remove it please do not down vote I just try to learn about programming ;-).\[code\]// Has User expressed his preference?if (!repositoryDevice.HasDevicePreference(userDevice)) // If not ...{ // Save the preference repositoryPreference.Add(userDevice.UserId, candidateId); result = true;}else // If yes ... { // If a User has express his preference more than 1 hour ago // allow the User to change his preference, otherwise not if (!HasUserRecentPreference(userDevice)) { repositoryPreference.Add(userDevice.UserId, candidateId); result = true; }}\[/code\]
 
Back
Top