Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Model section of developer guide #80

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the description if the BetterModelClassDiagram under Note: (line 140), the "Tag list in the AddressBook" can be specified to be UniqueTagList

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

The diagram appears fine in puml, but the arrows appear different in the docs.

Screenshot of the docs (some arrows are not pointing to their corresponding class)
Screenshot 2024-10-16 at 16 14 31

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a weird issue, no idea whats the issue

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