So in the last two weeks I have tried something new. It takes several hours of documentation, but it then allows for virtual planning in my code instead of direct manipulation.
In this particular set of problems (aka Tangled Knot) I have been assigned, there are about 60 different calls to the same function with varying input patterns.
First I create a spreadsheet listing out all the calling functions and then painstakingly recorded the inputs.
Second I color coded the inputs to their sources so that variables coming from the same source class were of the same color.
Then I could treat the whole problem as a Rubik's Cube (metaphorically) and rearrange the rows and columns in Excel until I found consistent patterns in the calls.
Then (for this particular problem) I was able to create wrapper functions that consolidated all the redundant calls. I was also able to rearrange the order of the original function arguments to put the least used optional arguments in the back and also greatly reduce the footprints of the original calls.
So using that approach I took out about 400 lines of code.
I got three lessons out of that:
1)
Quote:
|
Weeks of coding can save hours of planning
|
2) That whole Rubik's Cube trick might be pretty useful for other problems - basically tag the categories, and then work with the abstract categories to reduce the apparent complexity of the problem.
Quote:
Complexity is just a disarrangement of simplicity.
- George Abell
(former UCLA Aerospace Engineering professor)
|
3) The PFM is in the the ability to hide stuff

that is still there (optional arguments) and still can be used behind the scenes and pulled out at the drop of a hat when desired.
3a) There is of course, the alternative:
