The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
Let's say you have this scary complicated piece of code that no one understand. Yet it exhibit some issues.
After much effort you understand it and make a much simpler version. Chances are people will not accept the changes (can't commit without code review in some places, like my current place). For the simple reason that they have doubt the simple version is the same, since the current complicated version is gobbledigook no one understand.
The only committee approved solution to fix the spaghetti code issue is to wedge a few extra if statements in the middle of that some other quadruple nested if statements.
And so the spaghetti worsen...
And Integration Tests! If it's spaghetti code to start with then it probably has some pretty heavy dependencies on other classes, too. Don't mock or stub out those other classes. It's the only way to be sure.
Once you've stepped through every line of code and you have 80% + coverage of the class YOU will be THE expert.
Refactor the code with no logical changes on one change set. No bug fixes or enhancements allowed. Add lots of comments as you figure out why some line of code was added that seems counter-intuitive! Add a unit test to cover that line so that if anyone ever changes it or inverts the logic your test will catch it.
After the refactor, knock yourself out. You are now the SME.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
Refactoring code is generally seen as fairly high risk when there is a lot of code to change.
Do you use unit tests much where you work?
I would write some unit tests for the current code then refactor to prove that the unit tests are not broken.
Of course - the proof of not having broken anything will only be as good as your unit tests.
“That which can be asserted without evidence, can be dismissed without evidence.”
I think you may have started another "colour of the bike shed thread".
The premise being that in complicated decisions like approval for changes to a Nuclear reactor - everyone thinks its so complex they approve because someone else will have checked before them. But when choosing which colour to paint the bike shed - everyone wants to leave their mark - and so there can be no agreement on the best colour.
DO a google search - I'm sure the original discussion is described better than mine
That sounds like a variation of the Two Dances One Liquor pattern to me.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
Last Visit: 3-Jun-20 7:32 Last Update: 3-Jun-20 7:32