FamilySearch/gedcomx — Issue #129: Bad Object Oriented Design
Author: jralls
Created: 2012-02-08 06:21:20+00:00
State: open

The design of GedcomX reveals several bad characteristics:

* __Tight coupling between model and serialization classes__
Model classes (descendants of GenealogicalResource) should have no member variables of descendants of Reference. Reference classes should be filter functors which transform a Model class's serialization into a particular format. For example,
rdfString = rdfFormatter.format(myAttribution.serialize());

* __Type Member Variables__
Type and class are the same thing. It 's usually appropriate for a class to emit its name as part of serialization -- after all, the factory class will need it to pick the right kind of object to construct at deserialization, but it's redundant to have a member variable, and nonsensical to have getters and setters for it.

* __Getters and Setters__
You're writing a data interchange format. Model objects are immutable and need only three types of method: constructors, destructors (actually, only in non- gc languages), and serializers (two, I think: One for top-level objects and one for references to the object). Lose the getters and setters.

There's more, and I'll add them (or others can) as I continue to analyze the code.