Get all the Enumeratorz
-
I moved to a new job a couple of months ago. I'm working on extending existing product. It's quite mature as it's been developed for the past decade, so the code base is rather large. Many times often I need to dig into existing code. I find some strange things there, just a moment ago I found:
public override void ReverseProcess()
{
List actionsList;
// get actions
var actionsEnumerator = actionsList.GetEnumerator();
actionsEnumerator.Reset();
ReverseActions(actionsEnumerator);
}private void ReverseActions(IEnumerator actionsEnumerator)
{
while (actionsEnumerator.MoveNext())
{
automatedActionEO = (AutomatedActionEO)actionsEnumerator.Current;
//process action
}
}The code was written in 2013, so either someone is stacked on .NET 1.1 or thought that using
GetEnumerator()
in that way looks smart in the code, i.e. as if they knew some inner mechanisms of collections ;) There's a lot of weird things like this one in the inherited code. Most of them not harmful, just weird. -
I moved to a new job a couple of months ago. I'm working on extending existing product. It's quite mature as it's been developed for the past decade, so the code base is rather large. Many times often I need to dig into existing code. I find some strange things there, just a moment ago I found:
public override void ReverseProcess()
{
List actionsList;
// get actions
var actionsEnumerator = actionsList.GetEnumerator();
actionsEnumerator.Reset();
ReverseActions(actionsEnumerator);
}private void ReverseActions(IEnumerator actionsEnumerator)
{
while (actionsEnumerator.MoveNext())
{
automatedActionEO = (AutomatedActionEO)actionsEnumerator.Current;
//process action
}
}The code was written in 2013, so either someone is stacked on .NET 1.1 or thought that using
GetEnumerator()
in that way looks smart in the code, i.e. as if they knew some inner mechanisms of collections ;) There's a lot of weird things like this one in the inherited code. Most of them not harmful, just weird. -
Where exactly is the "reverse" part? For me this looks like the actions are processed in the normal forward order.
The good thing about pessimism is, that you are always either right or pleasently surprised.
My guess would be that it's "reverse" as in "undo", not "reverse" as in "go backwards".
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
I moved to a new job a couple of months ago. I'm working on extending existing product. It's quite mature as it's been developed for the past decade, so the code base is rather large. Many times often I need to dig into existing code. I find some strange things there, just a moment ago I found:
public override void ReverseProcess()
{
List actionsList;
// get actions
var actionsEnumerator = actionsList.GetEnumerator();
actionsEnumerator.Reset();
ReverseActions(actionsEnumerator);
}private void ReverseActions(IEnumerator actionsEnumerator)
{
while (actionsEnumerator.MoveNext())
{
automatedActionEO = (AutomatedActionEO)actionsEnumerator.Current;
//process action
}
}The code was written in 2013, so either someone is stacked on .NET 1.1 or thought that using
GetEnumerator()
in that way looks smart in the code, i.e. as if they knew some inner mechanisms of collections ;) There's a lot of weird things like this one in the inherited code. Most of them not harmful, just weird.The
foreach
operator is not an option I guess :) . Also, if they only wanted to reverse the list, why not use this? That is the forbidden stuff, and the unfaithful will be punished by torturing and banishing for forever. -
I moved to a new job a couple of months ago. I'm working on extending existing product. It's quite mature as it's been developed for the past decade, so the code base is rather large. Many times often I need to dig into existing code. I find some strange things there, just a moment ago I found:
public override void ReverseProcess()
{
List actionsList;
// get actions
var actionsEnumerator = actionsList.GetEnumerator();
actionsEnumerator.Reset();
ReverseActions(actionsEnumerator);
}private void ReverseActions(IEnumerator actionsEnumerator)
{
while (actionsEnumerator.MoveNext())
{
automatedActionEO = (AutomatedActionEO)actionsEnumerator.Current;
//process action
}
}The code was written in 2013, so either someone is stacked on .NET 1.1 or thought that using
GetEnumerator()
in that way looks smart in the code, i.e. as if they knew some inner mechanisms of collections ;) There's a lot of weird things like this one in the inherited code. Most of them not harmful, just weird. -
I moved to a new job a couple of months ago. I'm working on extending existing product. It's quite mature as it's been developed for the past decade, so the code base is rather large. Many times often I need to dig into existing code. I find some strange things there, just a moment ago I found:
public override void ReverseProcess()
{
List actionsList;
// get actions
var actionsEnumerator = actionsList.GetEnumerator();
actionsEnumerator.Reset();
ReverseActions(actionsEnumerator);
}private void ReverseActions(IEnumerator actionsEnumerator)
{
while (actionsEnumerator.MoveNext())
{
automatedActionEO = (AutomatedActionEO)actionsEnumerator.Current;
//process action
}
}The code was written in 2013, so either someone is stacked on .NET 1.1 or thought that using
GetEnumerator()
in that way looks smart in the code, i.e. as if they knew some inner mechanisms of collections ;) There's a lot of weird things like this one in the inherited code. Most of them not harmful, just weird.