diff options
| author | Szymon Szukalski <szymon@skas.io> | 2024-10-25 12:27:42 +1100 |
|---|---|---|
| committer | Szymon Szukalski <szymon@skas.io> | 2024-10-25 12:27:42 +1100 |
| commit | 1209b3b2302ac29deafbc88a29921a034b92dbb8 (patch) | |
| tree | d5312aba27a94fa3d8a0dcf5cf71636973cf680f /README.md | |
| parent | a07db1ed8d0179e29bd5d1ef3979a90613532596 (diff) | |
Update README
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 34 |
1 files changed, 14 insertions, 20 deletions
@@ -75,30 +75,24 @@ Based on the family tree, here are the expected outputs for commoon scenarios: ## Approach -### Data Model - -The data model revolves around four primary classes: `FamilyTree`, `FamilyFactory`, `Family`, and `Person`. - -#### `FamilyTree` - -Represents the entire family tree and ensures a single instance throughout the application using the Singleton pattern.\\ -It manages a collection of `Family` objects and the retrieval of various family relationships such as parents, uncles, aunts, and children. - -#### `FamilyFactory` +The implementation of this project follows a structured approach: -Responsible for creating and initializing predefined families. It uses helper methods to find or create individuals and establish relationships between them. +- **Testing**: All tests are written using RSpec. +- **Main Entrypoint**: The application is launched via `./bin/family_tree.rb`. +- **Command Line Interface**: Arguments are handled by the `CLI` class, which passes the actions file to the `ActionFileExecutor`. +- **Action Processing**: The `ActionFileExecutor` processes the actions file line by line, executing each action using the `FamilyTree`. +- **FamilyTree**: The `FamilyTree` singleton maintains a single instance of all families and exposes the `add_child` and `get_relationship` methods. +- **NilPerson Class**: The `NilPerson` class follows the Null Object pattern, providing a default, non-intrusive representation of a person when a real instance is not available. This helps avoid null checks throughout the application and simplifies code that interacts with `Person` objects. -#### `RelationshipManager` - -Manages the relationships between individuals, ensuring that connections like spouses, parents, and siblings are correctly established and maintained. - -#### `Family` - -Represents a family unit which is made up of a mother (`Person`), father (`Person`), and children (an array of `Person` objects). +### Data Model -#### `Person` +The data model revolves around four primary classes: `FamilyTree`, `FamilyFactory`, `Family`, and `Person`. -Represents an individual within the family tree, holding personal information and a reference to their spouse. A `Person` can exist in multiple families - as a **child** of one and as a **parent** (mother or father) of another. +- The `FamilyTree` follows the singleton pattern and provides functions for querying and modifying the family structure. +- The `FamilyFactory` uses the factory pattern to populate the `FamilyTree` during instantiation. +- The `Family` represents a unit comprising a mother, a father, and their children. +- A `Person` belongs to a `Family` and can appear as a child or as a parent (mother or father). +- A `Person` can be linked to another `Person` via the `spouse` attribute. ## Dependencies |
