I should point out that there was nothing horrendously bad about the code before I hit it. It could have been better documented, and there was excessive duplication, but it was logically sound, and there were no examples of the kind of baroque constructs, so beloved of one of the consultants who laid the groundwork for the system, which I've found in several other places.
Imagine a branching tree of if-then-elses, but with the same decisions deep in each fork. That's how I "inverted" it - taking one of the deeper if-then statements and pulling it out so it happened first - thereby eliminating a swathe of duplication. I also applied a few "else if" clauses to reduce repeated evaluation of string comparisons.
I'm probably going to have to answer a charge that I made the code MORE convoluted, but I reckon it was worth it for the performance improvement and centralised definition of constants. I think, once people grok it, my new code is actually no more complex than the old code, just very different in its approach to the problem.
no subject
Date: 2003-08-01 01:02 (UTC)Imagine a branching tree of if-then-elses, but with the same decisions deep in each fork. That's how I "inverted" it - taking one of the deeper if-then statements and pulling it out so it happened first - thereby eliminating a swathe of duplication. I also applied a few "else if" clauses to reduce repeated evaluation of string comparisons.
I'm probably going to have to answer a charge that I made the code MORE convoluted, but I reckon it was worth it for the performance improvement and centralised definition of constants. I think, once people grok it, my new code is actually no more complex than the old code, just very different in its approach to the problem.