Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

Talking about this

Arc next;
do
{
 next = arcList.FirstOrDefault(x => x.Visited == false);
 var temp = new List<Arc>();
 if (next == null) continue;
 do
 {
 next.Visited = true;
 temp.Add(next);
 if (next.Successor != null)
 {
 next = next.Successor;
 }
 else
 {
 break;
 }
 } while (true);
 arcListOfList.Add(temp);
} while (next != null); 
  • temp is almost always a bad name for a variable, at least if it stands on its own. Naming it tempArcList would be better but not ideal.

    temp is almost always a bad name for a variable, at least if it stands on its own. Naming it tempArcList would be better but not ideal.

    You should try to come up with a good and meaningful name.

You should try to come up with a good and meaningful name.

  • if (next == null) continue; this continue should be a break because the do..while will just end if next != null.

  • Using braces {} for single statement if, else` will help you to make your code less error prone. At least you have put the statement at the same line, which is a good start. Using braces would also (IMHO) improve the readability because it makes the statement more prominent.

  • If you invert the if (next.Successor != null) condition, you would reduce the horizontal spacing, hence improving readability.

  • you should always declare your variables as near as possible to their usage.

Implementing the above points would lead to this

Arc next;
do
{
 next = arcList.FirstOrDefault(x => x.Visited == false);
 if (next == null) { break; }
 var currentArcs= new List<Arc>();
 do
 {
 next.Visited = true;
 currentArcs.Add(next);
 if (next.Successor == null) { break; }
 next = next.Successor;
 } while (true);
 arcListOfList.Add(currentArcs);
} while (next != null); 

Talking about this

Arc next;
do
{
 next = arcList.FirstOrDefault(x => x.Visited == false);
 var temp = new List<Arc>();
 if (next == null) continue;
 do
 {
 next.Visited = true;
 temp.Add(next);
 if (next.Successor != null)
 {
 next = next.Successor;
 }
 else
 {
 break;
 }
 } while (true);
 arcListOfList.Add(temp);
} while (next != null); 
  • temp is almost always a bad name for a variable, at least if it stands on its own. Naming it tempArcList would be better but not ideal.

You should try to come up with a good and meaningful name.

  • if (next == null) continue; this continue should be a break because the do..while will just end if next != null.

  • Using braces {} for single statement if, else` will help you to make your code less error prone. At least you have put the statement at the same line, which is a good start. Using braces would also (IMHO) improve the readability because it makes the statement more prominent.

  • If you invert the if (next.Successor != null) condition, you would reduce the horizontal spacing, hence improving readability.

  • you should always declare your variables as near as possible to their usage.

Implementing the above points would lead to this

Arc next;
do
{
 next = arcList.FirstOrDefault(x => x.Visited == false);
 if (next == null) { break; }
 var currentArcs= new List<Arc>();
 do
 {
 next.Visited = true;
 currentArcs.Add(next);
 if (next.Successor == null) { break; }
 next = next.Successor;
 } while (true);
 arcListOfList.Add(currentArcs);
} while (next != null); 

Talking about this

Arc next;
do
{
 next = arcList.FirstOrDefault(x => x.Visited == false);
 var temp = new List<Arc>();
 if (next == null) continue;
 do
 {
 next.Visited = true;
 temp.Add(next);
 if (next.Successor != null)
 {
 next = next.Successor;
 }
 else
 {
 break;
 }
 } while (true);
 arcListOfList.Add(temp);
} while (next != null); 
  • temp is almost always a bad name for a variable, at least if it stands on its own. Naming it tempArcList would be better but not ideal.

    You should try to come up with a good and meaningful name.

  • if (next == null) continue; this continue should be a break because the do..while will just end if next != null.

  • Using braces {} for single statement if, else` will help you to make your code less error prone. At least you have put the statement at the same line, which is a good start. Using braces would also (IMHO) improve the readability because it makes the statement more prominent.

  • If you invert the if (next.Successor != null) condition, you would reduce the horizontal spacing, hence improving readability.

  • you should always declare your variables as near as possible to their usage.

Implementing the above points would lead to this

Arc next;
do
{
 next = arcList.FirstOrDefault(x => x.Visited == false);
 if (next == null) { break; }
 var currentArcs= new List<Arc>();
 do
 {
 next.Visited = true;
 currentArcs.Add(next);
 if (next.Successor == null) { break; }
 next = next.Successor;
 } while (true);
 arcListOfList.Add(currentArcs);
} while (next != null); 
Source Link
Heslacher
  • 50.9k
  • 5
  • 83
  • 177

Talking about this

Arc next;
do
{
 next = arcList.FirstOrDefault(x => x.Visited == false);
 var temp = new List<Arc>();
 if (next == null) continue;
 do
 {
 next.Visited = true;
 temp.Add(next);
 if (next.Successor != null)
 {
 next = next.Successor;
 }
 else
 {
 break;
 }
 } while (true);
 arcListOfList.Add(temp);
} while (next != null); 
  • temp is almost always a bad name for a variable, at least if it stands on its own. Naming it tempArcList would be better but not ideal.

You should try to come up with a good and meaningful name.

  • if (next == null) continue; this continue should be a break because the do..while will just end if next != null.

  • Using braces {} for single statement if, else` will help you to make your code less error prone. At least you have put the statement at the same line, which is a good start. Using braces would also (IMHO) improve the readability because it makes the statement more prominent.

  • If you invert the if (next.Successor != null) condition, you would reduce the horizontal spacing, hence improving readability.

  • you should always declare your variables as near as possible to their usage.

Implementing the above points would lead to this

Arc next;
do
{
 next = arcList.FirstOrDefault(x => x.Visited == false);
 if (next == null) { break; }
 var currentArcs= new List<Arc>();
 do
 {
 next.Visited = true;
 currentArcs.Add(next);
 if (next.Successor == null) { break; }
 next = next.Successor;
 } while (true);
 arcListOfList.Add(currentArcs);
} while (next != null); 
lang-cs

AltStyle によって変換されたページ (->オリジナル) /