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 ittempArcList
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 ittempArcList
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;
thiscontinue
should be a break because thedo..while
will just end ifnext != null
.Using braces
{}
for single statementif,
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 ittempArcList
would be better but not ideal.
You should try to come up with a good and meaningful name.
if (next == null) continue;
thiscontinue
should be a break because thedo..while
will just end ifnext != null
.Using braces
{}
for single statementif,
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 ittempArcList
would be better but not ideal.You should try to come up with a good and meaningful name.
if (next == null) continue;
thiscontinue
should be a break because thedo..while
will just end ifnext != null
.Using braces
{}
for single statementif,
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 ittempArcList
would be better but not ideal.
You should try to come up with a good and meaningful name.
if (next == null) continue;
thiscontinue
should be a break because thedo..while
will just end ifnext != null
.Using braces
{}
for single statementif,
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);