Would this pass code review where you are?
-
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
That's why I asked. Jumping into the middle of a
for
loop makes no sense to me.Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing. -
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
The first and most important question - does it work? The second question, how long ago was it written and what were the time-constraints and pressures of the project? It's easy to stand there and criticize other peoples work. Pretty sure no matter what you produce code-wise there will be better ways to do it either now or in the future. I never understand why people feel the need to post things like this - I'd guess some underlying insecurity issues...
-
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Certainly not. What would the loop variables be set to when you jumped into the middle of the loop? :wtf: You can sort-of mimic something similar with an
async
method, by putting ayield return;
in the inner loop. But IIRC, the compiler has to rewrite that as a state machine, because jumping into the middle of a loop just doesn't make any sense.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
The first and most important question - does it work? The second question, how long ago was it written and what were the time-constraints and pressures of the project? It's easy to stand there and criticize other peoples work. Pretty sure no matter what you produce code-wise there will be better ways to do it either now or in the future. I never understand why people feel the need to post things like this - I'd guess some underlying insecurity issues...
Apparently so, in C++. In C# (his target language) no - the label is out of scope of the goto. It was apparently written in 2006 ... and in my opinion you shouldn't try to perpetuate code crimes into new languages. To be honest, any coder who thinks nesting loops 5+ deep is a good idea probably needs a lesson in exponential growth ... :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
I review my own code - so I suppose, if I wrote it, it would pass. But I didn't - looks more like something one of our overseas contractors would do.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010
-
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
It's this new cool style of programming named For-Oriented Programming, or FOP for short. I think I'll try it out on my next project :thumbsup:
Best, Sander Azure Serverless Succinctly Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript
-
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Would be a good candidate for The Weird And The Wonderful forum, rather than the Lounge. I'm surprised it compiled. Shouldn't 'ep;' be 'ep:;'? I don't know since it is 43 years since I last wrote a goto statement (excluding for old languages that needed 'ON ERROR GOTO ..', and that was as recent as the late 1990s).
-
Would be a good candidate for The Weird And The Wonderful forum, rather than the Lounge. I'm surprised it compiled. Shouldn't 'ep;' be 'ep:;'? I don't know since it is 43 years since I last wrote a goto statement (excluding for old languages that needed 'ON ERROR GOTO ..', and that was as recent as the late 1990s).
-
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
First thoughts: It does not look very performant with 4 nested for loops, but it might be necessary, so need more information before commenting any more. Blink twice thoughts: Nuke that goto. Nuke it from space... This should not compile in C#. Wouldn't that have undefined behaviour in C, as the loop variables would not get initialised? It looks like the code that the goto label refers to is only executed from the goto, so perhaps the goto could be replaced by moving that code into the if statement. Good luck untangling this code.
-
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Well, it shows a good deal of promise. The author has very rigorously and helpfully identified (via comments) both the end of the method, and the end of the last
for
loop. Clearly s/he was in a great hurry, or maybe just wilfully lazy, as there is no equivalent commenting on the end of the inner loops. A smack on the wrist needed there, I think. Succinct and meaningful variable names used.i_n_
suggests a background in early BASIC, but that's fine; at least we know which level each variable relates to. There's a flag helpfully namedflag
, and a condition sensibly namedpass
. Well thought through. My criticism would be thatep
is obviously the "end procedure" goto target, but to perpetuate the camel case standard used in the method name, it should beeP
. Indentation is good and consistent. Not sure on the inlineif
but that may conform to local standards. Otherwise? meh. :| -
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
Apparently so, in C++. In C# (his target language) no - the label is out of scope of the goto. It was apparently written in 2006 ... and in my opinion you shouldn't try to perpetuate code crimes into new languages. To be honest, any coder who thinks nesting loops 5+ deep is a good idea probably needs a lesson in exponential growth ... :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Ooh, I thought C++ initialised variables to 0 by default - apparently not. So this is undefined behaviour if any of the loop variables are used after the goto is executed. Fnu
-
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Without context, it's hard to say what's going on but a thought occurs to me here; if there is no condition before that return statement, each loop level is going to execute only once so the whole logic could be flattened.
-
Without context, it's hard to say what's going on but a thought occurs to me here; if there is no condition before that return statement, each loop level is going to execute only once so the whole logic could be flattened.
who gave you permission to post my code on here? I thought the red printing at the top forbid that. edit: oops, sorry meant to reply to that other fellow.
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
-
Not sure what it does, especially goto part. But reminds of person who skipped recursion class...
Without knowing the range of the for loops, and how many there are, I wouldn't recommend recursion, because it might overflow the stack.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
OriginalGriff wrote:
code review where you are
On my current team, I'm the only one who writes "real code" -- and I definitely would not have written that. We've been required to do code reviews though... so we pretend to do code reviews of our SSIS packages. :confused:
-
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Maybe a self code review or the code review was sent to a subordinate/junior guy or a force approval. :)
Jim Rohn: "Don't wish it was easier, wish you were better". Subscribe to my blog @ https://jinnecesario.com/.
-
I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:
getSeries()
{if (flag == pass) goto ep;
for i1 ...
...
for i2 ...
...
for i3 ...
...
for i4 ...
.
.
.
for ...
{
...
return;
ep;
}
}
}
}//last for}// end of getSeries()
Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Isn't that the guy in QA that asked where to stick the goto? But I'm sure that's not where they told him to stick it.
I'm not sure how many cookies it makes to be happy, but so far it's not 27. JaxCoder.com
-
Isn't that the guy in QA that asked where to stick the goto? But I'm sure that's not where they told him to stick it.
I'm not sure how many cookies it makes to be happy, but so far it's not 27. JaxCoder.com
Yes - I'm trying to get him to see that I'm not the only one who looks at theat and sees Assembler code written in C compiled by a C++ compiler and never going to work in C# ... He thinks it's perfectly good code because it has worked since 2006. We all know that just because you can do something, it doesn't mean you should. I feel sorry for anyone who has to work for / with him - that company has to be the kiss of death for your career!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!