It really happened, legacy programmers tales
Join the DZone community and get the full member experience.Join For Free
fairy tales always start with “once upon a time”, and programmers tales starts with “when i was at a client”…
two days ago i was a client, and the discussion turned to bad code bases, as it often does. one story that i had hard time understanding was the super if.
basically, it looked like this:
i had a hard time accepting that someone could write an if condition that long. i kept assuming that they meant that the if statements were 50 lines long, but that wasn’t the case.
and then yesterday i had an even more horrifying story. a wcf service making a call to the database always timed out on the first request, but worked afterward. what would be your first suspicion? mine was that it took time to establish the database connection, and that after the first call the connection resided in the connection pool.
they laughed at my naivety, for it wasn’t connecting to the database that caused the timeout, it was jitting the method that the wcf service ended up calling.
yep, you got that right, jitting a single method (because the runtime only jit a single method at a time). i had even harder time believing that, until they explained to me how that method was built:
some interesting stats:
- it had a cyclomatic complexity of either 4,000 or 8,000, the client couldn’t remember.
- the entire rhino mocks codebase fits in 13,000 loc, so this single method could contain it several times over.
but you know what the really scary part is?
i upgraded from super if to black hole methods, and i am afraid to see what happen today, because if i get something that top the black hole method, i may have to hand back my keyboard and go raise olives.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.