- Display Family Tree
- Display Shortest Relation Chain
- Display Members from Generation Level
- Display Family Members in Ascending order of Age
- Display Family Members in Descending order of Age
- Display Male Family Members
- Display Female Family Members
- Display Aggregate Relation
- Display Persons by Relation (Ex: Display al Persons who are related to this Person as AUNTs)
- Display Persons Related to someone with Relation (Ex: Display all Persons who are MOTHERs to someone)
- Lombok - to auto-generate boiler plate code
- Google Guice - For Dependency Injection
- Gradle - For Build
- Java 8
- Family is represented as a Directed graph, with Persons as Nodes and Relations as Edges. Adjacency list graph representation is used.
- Edge is called 'Connection' and it holds From Person, To Person, Generic Relation and Relation Level.
- The system can support both Generic and Specific type of relations.
- Relation level of a connection represents the difference of levels above or below, between the persons in relation. It also helps in representing relations like GREAT GREAT GRANDPARENT or GREAT GRANDCHILD.
- graph stores only generic relations and they are converted back to specific relations based on gender.
- Most of the relations come in pairs, as one is reverse of the other and one is alternate to another. They are coupled
together, and one depends on another to get reverse relation in
getReverseRelation()
. - Specific relations are tied to generic relations with method:
getGenericRelation()
- Using enum to represent Relations, as all the relations have static state and enum promotes type safety.
- Classes are Loosely coupled, depending on interfaces rather than concrete implementations. Components can be replaced and extended easily.
- Classes are designed to be highly Cohesive.
- Most of the methods are Polymorphic, written for various use-cases.
- Template pattern followed for Relations, so that every relations implements a stipulated template of methods.
- Chain of Responsibilities pattern used for validation. Connections have to go through a series of validations like age, gender and possible relationships.
- Violated 'Law of Demeter' to reduce wrapping and complexity. Eg:
edge.relation().getGenericRelation()
- Violated SRP for DRY in methods like
traverseFamilyGraph(), load()
.
- PARENT, SIBLING, CHILD are direct relations and KIN, COUSIN, NIBLING are indirect relations. So, when there is no direct connection between two persons, they are assumed to have a indirect relation between them. For example, KIN of a CHILD is treated as COUSIN, instead of SIBLING.
- COUSIN is both generic and specific relation.
- KIN: Generic gender neutral word chosen to represent UNCLE and AUNT.
- NIBLING: Generic gender neutral word chosen to represent NEPHEW and NIECE
All Software written by Gopal S Akshintala, is licensed under MIT.