Skip to main content
added 2 characters in body
Source Link
Sandeepan Nath
  • 755
  • 1
  • 7
  • 15

Along with my previous answer, I'm going to add a new one I ran into today from my beast of an inherited project:

Copy/Paste

While debugging I ran into a piece of code calling 2 similarly named functions:

if(x) Func1 else Func2 

Func1 and Func2 had the same parameters. I pulled them out and diffed, and they are 100% the same except for Func1 calls Func3 and Func2 calls Func4. I pulled those out and diffed them. 100% the same, except for 1 line. So a previous programmer decided to copy and paste 2two 50 line nested-line-nested functions, instead of adding a flag parameter, to 2 private functions used in exactly 1 place. It makes me want to cry.

Along with my previous answer, I'm going to add a new one I ran into today from my beast of an inherited project:

Copy/Paste

While debugging I ran into a piece of code calling 2 similarly named functions:

if(x) Func1 else Func2 

Func1 and Func2 had the same parameters. I pulled them out and diffed, and they are 100% the same except for Func1 calls Func3 and Func2 calls Func4. I pulled those out and diffed them. 100% the same, except for 1 line. So a previous programmer decided to copy and paste 2 50 line nested functions, instead of adding a flag parameter, to 2 private functions used in exactly 1 place. It makes me want to cry.

Along with my previous answer, I'm going to add a new one I ran into today from my beast of an inherited project:

Copy/Paste

While debugging I ran into a piece of code calling 2 similarly named functions:

if(x) Func1 else Func2 

Func1 and Func2 had the same parameters. I pulled them out and diffed, and they are 100% the same except for Func1 calls Func3 and Func2 calls Func4. I pulled those out and diffed them. 100% the same, except for 1 line. So a previous programmer decided to copy and paste two 50-line-nested functions, instead of adding a flag parameter, to 2 private functions used in exactly 1 place. It makes me want to cry.

Post Made Community Wiki
Source Link
Jay
  • 1.9k
  • 13
  • 15

Along with my previous answer, I'm going to add a new one I ran into today from my beast of an inherited project:

Copy/Paste

While debugging I ran into a piece of code calling 2 similarly named functions:

if(x) Func1 else Func2 

Func1 and Func2 had the same parameters. I pulled them out and diffed, and they are 100% the same except for Func1 calls Func3 and Func2 calls Func4. I pulled those out and diffed them. 100% the same, except for 1 line. So a previous programmer decided to copy and paste 2 50 line nested functions, instead of adding a flag parameter, to 2 private functions used in exactly 1 place. It makes me want to cry.