Skip to content

Commit

Permalink
Merge pull request #80 from zaidansani/doc-dg-model
Browse files Browse the repository at this point in the history
Update Model section of developer guide
  • Loading branch information
rxchell authored Oct 18, 2024
2 parents 0d7b351 + 1c94a83 commit 73f4e38
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
17 changes: 12 additions & 5 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,26 @@ How the parsing works:
### Model component
**API** : [`Model.java`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/model/Model.java)

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

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

The `Model` component,

* 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.
* with regards to `Person` objects:
* stores the details of a person in a `PersonDescriptor` object
* stores the `PersonDescriptor` object with a `personId` in the `Person` class.
* 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.
* with regards to `Appointment` objects:
* stores the details of an appointment in a `AppointmentDescriptor` object
* stores the `AppointmentDescriptor` object with a `appointmentId` in the `Appointment` class.
* stores the address book data i.e., all `Appointment` objects (which are contained in a `UniqueAppointmentList` object).
* stores the currently 'selected' `Appointment` objects (e.g., results of a search query) as a separate _filtered_ list which is exposed to outsiders as an unmodifiable `ObservableList<Appointment>` 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 `Tag` list (the `UniqueTagList`) 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. Similarly, the `Appointment` objects are shown as such as well.<br>

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

Expand Down
6 changes: 5 additions & 1 deletion docs/diagrams/BetterModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ skinparam arrowThickness 1.1
skinparam arrowColor MODEL_COLOR
skinparam classBackgroundColor MODEL_COLOR

AppointmentBook *-left-> "1" UniqueAppointmentList
UniqueAppointmentList *-down-> "1" Appointment
Appointment *-left-> "1" Person

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

UniqueTagList -right-> "*" Tag
UniquePersonList -right-> Person
Expand Down
32 changes: 25 additions & 7 deletions docs/diagrams/ModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ skinparam classBackgroundColor MODEL_COLOR

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

Class UniquePersonList
Class Person
Class PersonDescriptor
Class Address
Class Email
Class Name
Class Phone
Class Tag

Class UniqueAppointmentList
Class Appointment
Class AppointmentDescriptor

Class I #FFFFFF
}

Expand All @@ -29,20 +36,30 @@ HiddenOutside ..> Model
AddressBook .up.|> ReadOnlyAddressBook

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

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

AppointmentBook *--> "1" UniqueAppointmentList
UniqueAppointmentList --> "~* all" Appointment
Appointment *--> "1" AppointmentDescriptor
AppointmentDescriptor *--> Person

Appointment -[hidden]down--> I
PersonDescriptor -[hidden]up--> I
Person -[hidden]up--> I
UniquePersonList -[hidden]right-> I

Expand All @@ -51,4 +68,5 @@ Phone -[hidden]right-> Address
Address -[hidden]right-> Email

ModelManager --> "~* filtered" Person
ModelManager --> "~* filtered" Appointment
@enduml

0 comments on commit 73f4e38

Please sign in to comment.