Eliminating obsolete code continues
I've made some significant progress with this, but now I'm getting down to the parts where I have obsolete properties entangled with similar live properties in method signatures and code blocks. I've managed to eliminate three of the four obsolete properties from MdhRecordList
: $isEmbedded
, $parentId
, and $parentIdField
. These are hardly used at all by other classes, so eliminating them was simply a local issue, with a few exceptions.
The remaining property is $parentSuffix
, and this is problematic because it's passed to any child MdhRecord
objects, and referenced throughout the code of both classes, although I don't believe it's actually used at all any more. This is what I believe to be the case, after my first reading of the code and comments:
- I don't believe any of the current code makes use of the
MdhRecordList::parentSuffix
property at all; it's set to an empty string and never changed. - However, it is invoked in many locations in the code. Where it occurs in direct functions writing out XHTML, I believe it could simply be eliminated.
- It is also passed to any child
MdhRecord
objects, where it is assigned toMdhRecord::parentSuffix
. Inside theMdhRecord
class this is frequently invoked. Generally it is chained together withMdhRecord::localSuffix
, a property which is used, and is essential, to ensure that individual forms and form elements have uniqueid
attributes. - The Adaptive Fields library
adaptive_fields.php
uses a property with the same name, but I don't believe there's any direct connection between the two. - When
MdhRecord
uses a suffix, it's usually done by calling itsgetSuffix()
method, which chains togetherparentSuffix
andlocalSuffix
. In current usage, since theparentSuffix
is always set to an empty string, I believe only thelocalSuffix
is ever written out.
Given this, I think this might be a suitably cautious approach to eliminating this complication:
- Start with
MdhRecordList
, and ensure that nothing can set the value of$parentSuffix
to anything except an empty string. Test thoroughly. - Next, move to
MdhRecord
, and ensure that nothing can set its$parentSuffix
to anything but an empty string. Test again. - If all is well, eliminate all uses of
$parentSuffix
fromMdhRecordList
and test again. This will leave the class making calls toMdhRecord
methods where it supplies an empty string in place of its$parentSuffix
. - Identify those methods in
MdhRecord
, and refactor them so that they don't require that parameter; then remove it from all calls to the methods. Test very thoroughly. - Remove all remaining code from
MdhRecordList
which references$parentSuffix
, and test again. - Remove all code referencing
$parentSuffix
fromMdhRecord
, and test again. - Examine
gui.js
. This has functions which look for the parent suffix and use it (although I believe it's always an empty string) to build ids for form elements and querystring parameters. Remove all references to it, and test again. - Look at get_rec.php and save_rec.php to see if mentions of suffixes and ids therecan now be simplified.
- Test test test test...