ここにコードのサンプルがあります。
このコードを書く他の方法を知りたいです。特に、ネストされた他のフォームについて知りたいif
です。
また、コメントについてのご意見をお聞かせください(ベストプラクティスは何ですか、私のコメントスタイルはプロの環境で十分ですか?)
この質問がSOの範囲外である場合は、お知らせください。削除します。反対票を投じないでください。プログラミングについて学習しようとしています;-)。
// 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;
}
}