Options Part 1: A Nightmare
I thought I would follow up with a two part message to stress the importance of design over hacking. Part 1 is “Options – A Nightmare”. Part 2 is “Options – A Success Story”. This is a real world case taken from the GRAMPS project.
Early in the project, we encountered the need to add the ability to suppress private information on export to GEDCOM. So, I approached it in the quick way. I added a button on the export, and a check in the code:
if not person.is_private(): write_person()
However, this quickly proved to be not enough. Names could be private. Events could be private. Sources could be private. So, more conditional checks where added. Dozens of:
if not person.is_private():
checks were added.
Then we discovered that Families could contain people marked private. So we added checks in the write_family() task.
We went from:
write_father_info(family.get_father()) write_mother_info(family.get_mother()) for child in family.get_children(): write_child_info(child)
to:
if not family.get_father().is_private(): write_father_info(family.get_father()) if not family.get_mother().is_private(): write_mother_info(family.get_mother()) for child in family.get_children(): if not child.is_private(): write_child_info(child)
But then, we realized that all members of a family could be private, in which case, we should not even output the family to the GEDCOM file. So you ended up with:
suppress_family = False if (not family.get_father().is_private and not family.get_mother().is_private()): suppress_family = True for child in family.get_children(): if child.is_private(): suppress_family = True if not suppress_family: if not family.get_father().is_private(): write_father_info(family.get_father()) if not family.get_mother().is_private(): write_mother_info(family.get_mother()) for child in family.get_children(): if not child.is_private(): write_child_info(child)
Similar approaches had to be done for nearly every possible object. And the GEDCOM export when from a simple set of code to a rather complex bit of code.
Then it became obvious that not only the GEDCOM export needed privacy information, but every report and every exporter. So something as seemingly simple as an option for handling privacy made simple code into complex code.
Of course, since each exporter and each report were different from each other, the code had to be written differently for each report. And in true form, we did not always get it right in every implementation. And, not every report and exporter was modified to handle the privacy
suppression.
This is the current status of GRAMPS 2.2. Our quick fix for privacy has lead to a coding and maintenance nightmare. Take a look at the bug tracker and see how many bugs are filed against privacy handling. The quick fix has lead to a major nightmare from the developer’s perspective (maintaining and supporting the code) and the user’s perspective (bugs and different results for different exporters and importers).