Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Being pressured to GOTO the dark-side

Tags:

goto

legacy

We have a situation at work where developers working on a legacy (core) system are being pressured into using GOTO statements when adding new features into existing code that is already infected with spaghetti code.

Now, I understand there may be arguments for using 'just one little GOTO' instead of spending the time on refactoring to a more maintainable solution. The issue is, this isolated 'just one little GOTO' isn't so isolated. At least once every week or so there is a new 'one little GOTO' to add. This codebase is already a horror to work with due to code dating back to or before 1984 being riddled with GOTOs that would make many Pastafarians believe it was inspired by the Flying Spaghetti Monster itself.

Unfortunately the language this is written in doesn't have any ready made refactoring tools, so it makes it harder to push the 'Refactor to increase productivity later' because short-term wins are the only wins paid attention to here...

Has anyone else experienced this issue whereby everybody agrees that we cannot be adding new GOTOs to jump 2000 lines to a random section, but continually have Anaylsts insist on doing it just this one time and having management approve it?

tldr;

How can one go about addressing the issue of developers being pressured (forced) to continually add GOTO statements (by add, I mean add to jump to random sections many lines away) because it 'gets that feature in quicker'?

I'm beginning to fear we may lose valuable developers to the raptors over this...

Credit: XKCD

Clarification:

Goto here

alsoThere: No, I'm talking about the kind of goto that jumps 1000 lines out of one subroutine into another one mid way into a while loop. Goto somewhereClose

there: I wasn't even talking about the kind of gotos you can reasonably read over and determine what a program was doing. Goto alsoThere

somewhereClose: This is the sort of code that makes meatballs midpoint: If first time here Goto nextpoint detail:(each one almost completely different) Goto pointlessReturn

here: In this question, I was not talking about the occasionally okay use of a goto. Goto there

tacoBell: and it has just gone back to the drawing board. Goto Jail

elsewhere: When it takes Analysts weeks to decypher what a program is doing each time it is touched, something is deeply wrong with your codebase. In fact, I'm actually up to my hell:if not up-to-date goto 4 rendition of the spec goto detail pointlessReturn: goto tacoBell

Jail: Actually, just a small update with a small victory. I spent 4 hours refactoring a portion of this particular program a single label at a time, saving each iteration in svn as I went. Each step (about 20 of them) was smallish, logical and easy enough to goto bypass nextpoint: spontaneously jump out of your meal and onto you screen through some weird sort of spaghetti-meatball magnetism. Goto elseWhere bypass: reasonably verify that it should not introduce any logic changes. Using this new more readable version, I've sat down with the analyst and completed almost all of this change now. Goto end

4: first *if first time here goto hell, no second if first time here goto hell, no third if first time here goto hell fourth now up-to-date goto hell

end:

like image 351
Dan McGrath Avatar asked May 26 '10 04:05

Dan McGrath


People also ask

What happens when you turn to the dark side?

The Jedi knew that the dark side is fear, leading to anger, which in turn leads to hatred, and finally leading to suffering—mostly for the one who embraced the dark side. The Jedi conquered their dark side through patience, training and discipline, thereby not giving it power over themselves.

Why do people turn to dark side?

We know what leads to the dark side: pain, suffering, fear, anger, jealousy and similar negative emotions. Attachments makes you more likely to feel these emotions, and as such are forbidden by the Jedi. The darkside is often described as selfish, while the light side is often described as selfless.

What is toxic resilience?

Toxic resilience describes a bounce-back from stress and tension that harms ourselves and/or others. The pressure that we have experienced has revealed flaws or weaknesses that distort our normal behaviour. We may recover at one level but also see and experience the world differently.

Did the Jedi push Anakin to the dark side?

But these are not the only things that had led him astray. The Jedi themselves were some of the biggest reasons Anakin was pushed to become Darth Vader.


1 Answers

How many bugs have been introduced because of incorrectly written GOTOs? How much money did they cost the company? Turn the issue into something concrete, rather than "this feels bad". Once you can get it recognized as a problem by the people in charge, turn it into a policy like, "no new GOTOs for anything except simplifying the exit logic for a function", or "no new GOTOs for any functions that don't have 100% unit test coverage". Over time, tighten the policies.

like image 171
twk Avatar answered Oct 06 '22 21:10

twk