📝 Update Readme

main
Alexis Drai 2 years ago
parent 9097f14601
commit efa89c4d3d

@ -45,50 +45,39 @@ Finally, users can create a `subject` when in edit mode. After clicking on *'Mo
## Architecture ## Architecture
Graduator is based on the MVVM (Model-View-ViewModel) architectural pattern. The below UML class diagram details the structure of the models, viewmodels, and views for `UnitsManager`, `Unit`, and `Subject`. Graduator is based on the MVVM (Model-View-ViewModel) architectural pattern. The below UML class diagram details
the structure of the models, viewmodels, and views for `UnitsManager`, `Unit`, and `Subject`. Notice how,
to circumvent [this issue](https://codefirst.iut.uca.fr/documentation/mchSamples_Apple/docusaurus/iOS_MVVM_guide/docs/viewModels/changeNotifications/problematic/),
we insert an entire hierarchy of VMs in certain views, so that they can update all those VMs when a detail gets edited. It's dirty, and it's staying that way for the foreseeable future.
```mermaid ```mermaid
classDiagram classDiagram
class Unit {
+name: String
+weight: Int
+isProfessional: Bool
+code: Int
+subjects: [Subject]
+getAverage(): Double?
+data: Data
+update(from: Data): Void
}
class MainView
class UnitView
class SubjectViewCell
class UnitsManagerVM {
-original: UnitsManager
+model: UnitsManager.Data
+isEdited: Bool
+isAllEditable: Bool
+updateUnit(unitVM: UnitVM): Void
+TotalAverage: Double?
+ProfessionalAverage: Double?
}
class UnitVM { class UnitVM {
-original: Unit -original: Unit
+model: Unit.Data +model: Unit.Data
+isEdited: Bool +isEdited: Bool
+SubjectsVM: [SubjectVM] +onEditing()
+onEditing(): Void +onEdited(isCancelled: Bool)
+onEdited(isCancelled: Bool): Void +updateSubject(subjectVM: SubjectVM)
+updateSubject(subjectVM: SubjectVM): Void +updateAllSubjects()
+updateAllSubjects(): Void +deleteSubject(subjectVM: SubjectVM)
+deleteSubject(subjectVM: SubjectVM): Void +addSubject(subject: Subject)
+addSubject(subject: Subject): Void
+Average: Double? +Average: Double?
} }
class UnitView {
-unitVM: UnitVM
-unitsManagerVM: UnitsManagerVM
+delete(at: IndexSet): Void
}
class Subject {
+name: String
+weight: Int
+grade: Double?
+gradeIsValid(grade: Double?): Bool
+data: Data
+update(from: Data): Void
}
class SubjectVM { class SubjectVM {
-original: Subject -original: Subject
+model: Subject.Data +model: Subject.Data
@ -96,51 +85,52 @@ classDiagram
+onEditing(): Void +onEditing(): Void
+onEdited(isCancelled: Bool): Void +onEdited(isCancelled: Bool): Void
} }
class SubjectViewCell {
-subjectVM: SubjectVM
-unitVM: UnitVM
-unitsManagerVM: UnitsManagerVM
-isGradeEditable: Bool
}
class UnitsManager { class UnitsManager {
+units: [Unit]
+getTotalAverage(): Double? +getTotalAverage(): Double?
+getProfessionalAverage(): Double? +getProfessionalAverage(): Double?
+getAverage(units: [Unit]): Double? +getAverage(units: Unit[]): Double?
+data: Data +data: Data
+update(from: Data): Void +update(from: Data): Void
} }
class Unit {
class UnitsManagerVM { +name: String
-original: UnitsManager +weight: Int
+model: UnitsManager.Data +isProfessional: Bool
+isEdited: Bool +code: Int
+isAllEditable: Bool +subjects: Subject[]
+UnitsVM: [UnitVM] +getAverage(): Double?
+updateUnit(unitVM: UnitVM): Void +data: Data
+TotalAverage: Double? +update(from: Data): Void
+ProfessionalAverage: Double?
} }
class Subject {
class MainView { +name: String
-unitsManagerVM: UnitsManagerVM +weight: Int
+grade: Double?
+gradeIsValid(grade: Double?): Bool
+data: Data
+update(from: Data): Void
} }
UnitVM -- Unit : Uses MainView --> UnitsManagerVM
UnitView -- UnitVM : Observes UnitView --> UnitVM
SubjectVM -- Subject : Uses UnitView --> UnitsManagerVM
SubjectViewCell -- SubjectVM : Observes SubjectViewCell --> SubjectVM
UnitVM "1" o-- "*" SubjectVM : Contains SubjectViewCell --> UnitVM
UnitsManagerVM -- UnitsManager : Uses SubjectViewCell --> UnitsManagerVM
UnitsManagerVM "1" o-- "*" UnitVM : Contains
MainView -- UnitsManagerVM : Observes UnitsManagerVM --> "*" UnitVM
UnitsManagerVM --> UnitsManager
UnitVM --> "*" SubjectVM
UnitVM --> Unit
SubjectVM --> Subject
``` ```
It might be useful to note that, just like `UnitVM`s aggregate `SubjectVM`s, `Unit`s aggregate `Subject`s, but these relationship between `Model` entities were removed from the diagram above for clarity. It might be useful to note that, just like `UnitVM`s aggregate `SubjectVM`s, `Unit`s aggregate
`Subject`s, but these relationship between `Model` entities were removed from the diagram above for clarity.
The same is true with the View-related classes.
Here is the diagram with those relationships depicted. Here is the diagram with those relationships depicted.
@ -149,93 +139,81 @@ Here is the diagram with those relationships depicted.
```mermaid ```mermaid
classDiagram classDiagram
class Unit {
+name: String
+weight: Int
+isProfessional: Bool
+code: Int
+subjects: [Subject]
+getAverage(): Double?
+data: Data
+update(from: Data): Void
}
class MainView
class UnitView
class SubjectViewCell
class UnitsManagerVM {
-original: UnitsManager
+model: UnitsManager.Data
+isEdited: Bool
+isAllEditable: Bool
+updateUnit(unitVM: UnitVM)
+TotalAverage: Double?
+ProfessionalAverage: Double?
}
class UnitVM { class UnitVM {
-original: Unit -original: Unit
+model: Unit.Data +model: Unit.Data
+isEdited: Bool +isEdited: Bool
+SubjectsVM: [SubjectVM] +onEditing()
+onEditing(): Void +onEdited(isCancelled: Bool)
+onEdited(isCancelled: Bool): Void +updateSubject(subjectVM: SubjectVM)
+updateSubject(subjectVM: SubjectVM): Void +updateAllSubjects()
+updateAllSubjects(): Void +deleteSubject(subjectVM: SubjectVM)
+deleteSubject(subjectVM: SubjectVM): Void +addSubject(subject: Subject)
+addSubject(subject: Subject): Void
+Average: Double? +Average: Double?
} }
class UnitView {
-unitVM: UnitVM
-unitsManagerVM: UnitsManagerVM
+delete(at: IndexSet): Void
}
class Subject {
+name: String
+weight: Int
+grade: Double?
+gradeIsValid(grade: Double?): Bool
+data: Data
+update(from: Data): Void
}
class SubjectVM { class SubjectVM {
-original: Subject -original: Subject
+model: Subject.Data +model: Subject.Data
+isEdited: Bool +isEdited: Bool
+onEditing(): Void +onEditing()
+onEdited(isCancelled: Bool): Void +onEdited(isCancelled: Bool)
} }
class SubjectViewCell {
-subjectVM: SubjectVM
-unitVM: UnitVM
-unitsManagerVM: UnitsManagerVM
-isGradeEditable: Bool
}
class UnitsManager { class UnitsManager {
+units: [Unit]
+getTotalAverage(): Double? +getTotalAverage(): Double?
+getProfessionalAverage(): Double? +getProfessionalAverage(): Double?
+getAverage(units: [Unit]): Double? +getAverage(units: Unit[]): Double?
+data: Data +data: Data
+update(from: Data): Void +update(from: Data)
}
class UnitsManagerVM {
-original: UnitsManager
+model: UnitsManager.Data
+isEdited: Bool
+isAllEditable: Bool
+UnitsVM: [UnitVM]
+updateUnit(unitVM: UnitVM): Void
+TotalAverage: Double?
+ProfessionalAverage: Double?
} }
class Unit {
class MainView { +name: String
-unitsManagerVM: UnitsManagerVM +weight: Int
+isProfessional: Bool
+code: Int
+getAverage(): Double?
+data: Data
+update(from: Data)
} }
class Subject {
UnitVM -- Unit : Uses +name: String
UnitView -- UnitVM : Observes +weight: Int
SubjectVM -- Subject : Uses +grade: Double?
SubjectViewCell -- SubjectVM : Observes +gradeIsValid(grade: Double?): Bool
UnitVM "1" o-- "*" SubjectVM : Contains +data: Data
Unit "1" o-- "*" Subject : Contains +update(from: Data)
UnitsManagerVM -- UnitsManager : Uses }
UnitsManagerVM "1" o-- "*" UnitVM : Contains
UnitsManager "1" o-- "*" Unit : Contains MainView --> "*" UnitView
MainView -- UnitsManagerVM : Observes MainView --> UnitsManagerVM
UnitView --> "*" SubjectViewCell
UnitView --> UnitVM
UnitView --> UnitsManagerVM
SubjectViewCell --> SubjectVM
SubjectViewCell --> UnitVM
SubjectViewCell --> UnitsManagerVM
UnitsManagerVM --> "*" UnitVM
UnitsManagerVM --> UnitsManager
UnitVM --> "*" SubjectVM
UnitVM --> Unit
SubjectVM --> Subject
UnitsManager --> "*" Unit
Unit --> "*" Subject
``` ```

Loading…
Cancel
Save