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.
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
Some people has WAAAAAY too much time on their hands!
Anything that is unrelated to elephants is irrelephant Anonymous - The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944 - Never argue with a fool. Onlookers may not be able to tell the difference. Mark Twain