Skip to content

Commit

Permalink
Merge pull request #90 from Blizzeracz/update/DG-Model
Browse files Browse the repository at this point in the history
Update Model for DG
  • Loading branch information
euchangxian committed Oct 31, 2023
2 parents b96f812 + 46127a2 commit f9ce6c3
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 59 deletions.
15 changes: 8 additions & 7 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,22 @@ How the parsing works:
* All `XYZCommandParser` classes (e.g., `AddAnimalCommandParser`, `DeleteAnimalCommandParser`, ...) inherit from the `AnimalParser` interface so that they can be treated similarly where possible e.g, during testing.

### Model component
**API** : [`Model.java`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/model/Model.java)
**API** : [`AnimalModel.java`](https://github.com/AY2324S1-CS2103T-F08-3/tp/blob/master/src/main/java/seedu/address/model/AnimalModel.java)

<puml src="diagrams/ModelClassDiagram.puml" width="450" />


The `Model` component,
The `AnimalModel` component,

* stores the animal catalog data i.e., all `Animal` objects (which are contained in a `UniqueAnimalList` object).
* stores the currently 'selected' `Animal` objects (e.g., results of a search query) as a separate _filtered_ list which is exposed to outsiders as an unmodifiable `ObservableList<Animal>` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
* stores a `AnimalUserPref` object that represents the user’s preferences. This is exposed to the outside as a `AnimalReadOnlyUserPref` objects.
* does not depend on any of the other three components (as the `AnimalModel` represents data entities of the domain, they should make sense on their own without depending on other components)

* stores the address book data i.e., all `Person` objects (which are contained in a `UniquePersonList` object).
* stores the currently 'selected' `Person` objects (e.g., results of a search query) as a separate _filtered_ list which is exposed to outsiders as an unmodifiable `ObservableList<Person>` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
* stores a `UserPref` object that represents the user’s preferences. This is exposed to the outside as a `ReadOnlyUserPref` objects.
* does not depend on any of the other three components (as the `Model` represents data entities of the domain, they should make sense on their own without depending on other components)

<box type="info" seamless>

**Note:** An alternative (arguably, a more OOP) model is given below. It has a `Tag` list in the `AddressBook`, which `Person` references. This allows `AddressBook` to only require one `Tag` object per unique tag, instead of each `Person` needing their own `Tag` objects.<br>
**Note:** An alternative (arguably, a more OOP) model is given below. It has a `PetId` list in the `AnimalCatalog`, which `Animal` can reference. This allows `AnimalCatalog` to only require `PetId` object, instead of each `Animal` needing their own `PetId` objects.<br>

<puml src="diagrams/BetterModelClassDiagram.puml" width="450" />

Expand Down
24 changes: 13 additions & 11 deletions docs/diagrams/BetterModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ skinparam arrowThickness 1.1
skinparam arrowColor MODEL_COLOR
skinparam classBackgroundColor MODEL_COLOR

AddressBook *-right-> "1" UniquePersonList
AddressBook *-right-> "1" UniqueTagList
UniqueTagList -[hidden]down- UniquePersonList
UniqueTagList -[hidden]down- UniquePersonList
AnimalCatalog *-right-> "1" UniqueAnimalList
AnimalCatalog *-right-> "1" UniquePetIdList

UniqueTagList -right-> "*" Tag
UniquePersonList -right-> Person
UniquePetIdList -[hidden]down- Animal

Person -up-> "*" Tag
UniquePetIdList -right-> "*" PetId
UniqueAnimalList -right-> Animal

Person *--> Name
Person *--> Phone
Person *--> Email
Person *--> Address
Animal -up-> "*" PetId

Animal *--> Name
Animal *--> Species
Animal *--> Breed
Animal *--> Sex
Animal *--> DateOfBirth
Animal *--> AdmissionDate
@enduml
82 changes: 41 additions & 41 deletions docs/diagrams/ModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,51 @@ skinparam arrowThickness 1.1
skinparam arrowColor MODEL_COLOR
skinparam classBackgroundColor MODEL_COLOR

Package Model as ModelPackage <<Rectangle>>{
Class "<<interface>>\nReadOnlyAddressBook" as ReadOnlyAddressBook
Class "<<interface>>\nReadOnlyUserPrefs" as ReadOnlyUserPrefs
Class "<<interface>>\nModel" as Model
Class AddressBook
Class ModelManager
Class UserPrefs

Class UniquePersonList
Class Person
Class Address
Class Email
Package AnimalModel as AnimalModelPackage <<Rectangle>>{
Class "<<interface>>\nAnimalReadOnlyCatalog" as AnimalReadOnlyCatalog
Class "<<interface>>\nAnimalReadOnlyAnimalUserPrefs" as AnimalReadOnlyAnimalUserPrefs
Class "<<interface>>\nAnimalModel" as AnimalModel
Class AnimalCatalog
Class AnimalModelManager
Class AnimalUserPrefs

Class UniqueAnimalList
Class Animal
Class Name
Class Phone
Class Tag
Class PetId
Class Species
Class Breed
Class Sex
Class DateOfBirth
Class AdmissionDate

Class I #FFFFFF
}

Class HiddenOutside #FFFFFF
HiddenOutside ..> Model

AddressBook .up.|> ReadOnlyAddressBook

ModelManager .up.|> Model
Model .right.> ReadOnlyUserPrefs
Model .left.> ReadOnlyAddressBook
ModelManager -left-> "1" AddressBook
ModelManager -right-> "1" UserPrefs
UserPrefs .up.|> ReadOnlyUserPrefs

AddressBook *--> "1" UniquePersonList
UniquePersonList --> "~* all" Person
Person *--> Name
Person *--> Phone
Person *--> Email
Person *--> Address
Person *--> "*" Tag

Person -[hidden]up--> I
UniquePersonList -[hidden]right-> I

Name -[hidden]right-> Phone
Phone -[hidden]right-> Address
Address -[hidden]right-> Email

ModelManager --> "~* filtered" Person
HiddenOutside ..> AnimalModel

AnimalCatalog .up.|> AnimalReadOnlyCatalog

AnimalModelManager .up.|> AnimalModel
AnimalModel .right.> AnimalReadOnlyAnimalUserPrefs
AnimalModel .left.> AnimalReadOnlyCatalog
AnimalModelManager -left-> "1" AnimalCatalog
AnimalModelManager -right-> "1" AnimalUserPrefs
AnimalUserPrefs .up.|> AnimalReadOnlyAnimalUserPrefs

AnimalCatalog *--> "1" UniqueAnimalList
UniqueAnimalList --> "~* all" Animal
Animal *--> Name
Animal *--> Breed
Animal *--> Species
Animal *--> PetId
Animal *--> Sex
Animal *--> DateOfBirth
Animal *--> AdmissionDate

Animal -[hidden]up--> I
UniqueAnimalList -[hidden]right-> I

AnimalModelManager --> "~* filtered" Animal
@enduml

0 comments on commit f9ce6c3

Please sign in to comment.