I once had to print a method that took 50 pages of paper, so I could understand what it does, and after 15 minutes I realized it's the same 60 lines repeated over and over with different conditions. The guy who wrote it had no idea he could have extracted a method.
back
From my experience, such code is not specific to MS technologies, but is indeed often found in “enterprisey” code, a lot of which just happens to be in Java and C#. And enterprisey code is like that because it's often outsourced to the lowest bidder.
3 comments
I replaced an old AS400 system from the 70s as one of my first gigs. It was 50k lines of incomprehensible RPG code. I would often have to print out the code, steal a conference room, lay out all the pages, and go to town with a bunch of highlighters to tell what the hell was going on.
On the plus side, the code still had comments for the punchcard numbers, so it was pretty easy to keep the pages in order :)
Just curious: Why does printing it on paper helps you to understand code better than reading it on screen?
Every once in a while you find code whose control structures are wrapped around a ton of working code... paging up and down to try to grok the entire structure pagefaults my short term memory badly enough that having it all visible at once is the only workaround.
Sometimes, if you're really lucky, the blocks of working code don't modify their own conditionals, and you can 'fold' them and just look at the if's and loops...
For me, the ability to spread the paper across a table and look at many different parts of the code simultaneously. It's like having a giant high resolution monitor.
Also, faster and more flexible annotation (drawings, etc), but that's secondary.
I've only had to print terrible code to understand it. I think it's a way to leverage the spatial part of your brain more directly.... where was that part of this huge method that did that... oh, it's top left.
It helps to understand the structure. I was looking for repetitions (and luckily I found a lot), but I needed to look out for things that change between repetitions.
I just found the picture I took that day. The boxing gloves just happened to be in the same conf room.
Looking as close as I can at those printouts, my only reaction is, "that's CODE?!" Good lord.
Because if you can find a room with enough table space you can lay out all of the code at once instead of having to jump back and forward on a small screen.
A 4x6 table has far more surface area than even the biggest multi monitor set up
This is my life.