Skip to content

Commit 793f722

Browse files
committed
Fix things
1 parent 1b398da commit 793f722

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

ARCHITECTURE.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Navitia provides two routes that TNPR uses:
1414

1515
### Layers
1616

17-
TNPR follows the MVVM architecture. Well, at leat it follows my interpretation of it.
17+
TNPR follows the MVVM architecture. Well, at least it follows my interpretation of it.
1818

1919
![](README_assets/layers.png)
2020

@@ -26,7 +26,7 @@ In this diagram, you see:
2626
- The ViewModel: as [the Presentation Model described by Martin Fowler](https://martinfowler.com/eaaDev/PresentationModel.html), this is "an abstract of the view that is not dependent on a specific GUI framework".
2727
So theoretically, it could be reused in any app targeting any UI framework e.g. Android, iOS or the web using Kotlin Multiplatform, Android or the desktop using Compose...
2828
- The Model: this is where TNPR's "intelligence" resides.
29-
When the app has to process data, it does it by converting the data into internal representation that is not at all tied to the view (ViewModel → Model), does the processing (`processingModel = model(data)`), and then converts the data into a representation (`uiState.updatedWith(processingModel)`) that can be easily displayed by the View (Model → ViewModel).
29+
When the app has to process data, it does it by converting the data into internal representation that is not at all tied to the View (ViewModel → Model), does the processing (`processingModel = model(data)`), and then converts the data into a representation (`uiState.updatedWith(processingModel)`) that can be easily displayed by the View (Model → ViewModel).
3030
TNPR does not have a proper `model` package or classes, but the `model(data)` is defined as a pure function: it only converts data, applying computations in the process.
3131
- The "cloud" (mainly Navitia web services)
3232

@@ -35,17 +35,18 @@ To learn more about that, see [the MVVM experiment section](#mvvm-viewviewmodelm
3535
### Dependencies
3636

3737
The dependencies of TNPR can be represented in two ways:
38-
- Abstract, where each dependency is labeled in a generic way, independant of the framework: "standard library", "type-safe HTTP client"...
39-
This exact representation of the dependencies could apply to the same application not targeting Android, but instead a web browser or a desktop OS.
40-
- Concrete, where each dependency is labeled specifically as the implementation that is used in TNPR: "standard libary" → `kotlin.stdlib`, "type-safe HTTP client" → `com.squareup.retrofit2`.
38+
39+
- **Abstract**, where each dependency is labeled in a generic way, independant of the framework: "standard library", "type-safe HTTP client"...
40+
This representation of the dependencies could apply to the same application not targeting Android, but instead a web browser or a desktop OS.
41+
- **Concrete**, where each dependency is labeled specifically as the implementation that is used in TNPR: "standard libary" → `kotlin.stdlib`, "type-safe HTTP client" → `com.squareup.retrofit2`.
4142

4243
| Concrete | Abstract |
4344
|------------------------------------------|------------------------------------------|
4445
| ![](README_assets/deps-concrete.png) | ![](README_assets/deps-abstract.png) |
4546

4647
Each diagram is split into high-level packages: Application, Network, UI, Runtime environment and Language.
4748

48-
Read on to learn about these packages.
49+
Read on to learn more about these packages.
4950

5051
#### Application (`me.cpele`)
5152

@@ -65,15 +66,15 @@ These libraries have been chosen because they are well established and widely kn
6566

6667
Some UI components come from [Material Components](https://material.io/components?platform=android).
6768

68-
Why? Material components are cross-platform, abundantly documented and commonly used.
69+
Why? Material components are cross-platform, documented and commonly used.
6970

7071
## Language: `org.jetbrains`
7172

7273
The app depends on this package that provides the Kotlin standard library (`kotlin.stdlib`) and the Coroutines library (`kotlinx.coroutines`).
7374

74-
Coroutines are used to implement asynchronous operations like calls to web services.
75+
Coroutines are used to implement asynchronous operations like calling web services.
7576

76-
Flows are used to implement asynchronous operations reperesented as streams, for example it allows to handle the user input in the Autosuggest screen.
77+
`Flow`s are used to implement asynchronous operations reperesented as streams, for example it allows to handle the user input in the Autosuggest screen.
7778

7879
## Runtime environment: `androidx`
7980

@@ -85,7 +86,7 @@ The `core` subpackage is for extensions of the Android SDK, it brings e.g. `View
8586

8687
`appcompat` implements components that supersed those that come with the Android SDK, it has better backward and forward compatibiliy e.g. `ActivityCompat`.
8788

88-
`navigation` is the Jetpack component to implement navigation. It has drawbacks, mostly in the dependency relations it requires, but it was a simple way to design the app's navigation efficiently. It also provides editing tools that offer a global view of the app's UI, as you'll see [in the Features section](#features-diagram).
89+
`navigation` is the Jetpack component to implement navigation. It has drawbacks, mostly in the dependency relations it requires, but it was a simple way to design the app's navigation quickly. It also provides editing tools that offer a global view of the app's UI, as you'll see [in the Features section](#features-diagram).
8990

9091
### Features
9192

@@ -95,18 +96,18 @@ Thanks to Jetpack Navigation, here is a diagram showing all of the app's screens
9596

9697
### Experiments
9798

98-
This app was a way for me to try a few things I could not try on my day job as and Android developer. In this section you'll find some of the experiments I tried.
99+
This app was a way for me to try a few things I could not try on my day job as an Android developer. In this section you'll find some of the experiments I tried.
99100

100101
#### Transmodel data model
101102

102-
Transmodel is the name of a reference data model to represent public transport data. I tried to use it as the internal data model of the application, but decided not to use it.
103+
Transmodel is the name of a european reference data model to represent public transport data. I tried to use it as the internal data model of the application, but decided not to.
103104

104105
Transmodel is a complex model, its complexity comes from features which were not useful for the purpose of TNPR, notably:
105106

106-
- Separate concepts for the spatial and temporal aspects of transport data
107-
- A representation for passengers, drivers and other types of "users" of public tranport modes
107+
- Separate representations for the spatial and temporal aspects of transport data
108+
- A representation for passengers, drivers and other types of users of public tranport modes
108109

109-
I choosed to stay with a projection of the Navitia data model. By "projection" I mean that I took the model as is, only keeping the resources and attributes I wanted TNPR to manage. Navitia's model is simpler and better suited for an application that is only targeted at passengers.
110+
I choosed to use a simpler data model, which is a projection of the Navitia data model. By "projection" I mean that I took the Navitia model as is, only keeping the resources and attributes I wanted TNPR to manage. Navitia's model is better suited for an application that is only targeted at passengers.
110111

111112
#### AFK custom framework
112113

@@ -119,7 +120,7 @@ It contains:
119120
- `Component`: this is an interface that can be implemented by the app's `ViewModel`s:
120121
- It has a `dispatch(Action)` method which executes an `Action`. An `Action` could be e.g. `LoadData(id: Int)` to trigger a request to a web service and load data, or `SearchJourneys(origin: Place, destiation: Place)` to find a journey from a point A to a point B.
121122
- It has a `stateLive` property representing the "state" or "model" of a view, expressed in a way that should be independent of the UI framework.
122-
- It has an `eventLive` property that allows one-shot "events" or "effects" to come back to the UI without forcing the `Component` to retain a reference to the view.
123+
- It has an `eventLive` property that allows one-shot "events" or "effects" to come back to the UI without forcing the `Component` to retain a reference to the View.
123124

124125
- Some utility classes or functions:
125126
- `ViewModelFactory`: a generic `ViewModelProvider.Factory` that is used to instantiate a `ViewModel` from an `Activity` or a `Fragment` like this:
@@ -315,7 +316,7 @@ override fun onActivityCreated(savedInstanceState: Bundle?) {
315316
}
316317
```
317318

318-
And here is `RoadmapViewModel.load()`. It sends an `Input.Start`:
319+
Here is `RoadmapViewModel.load()`. It sends an `Input.Start`:
319320

320321
```kotlin
321322
fun load(tripId: String) {
@@ -345,7 +346,7 @@ fun load(tripId: String) {
345346
}
346347
```
347348

348-
😅
349+
Easy 😅
349350

350351
This experiment should be conducted in a more complex use case, but I have the intuition that it would not be worth it. Perhaps when the app has to interact with many third party SDKs or frameworks? I don't know.
351352

0 commit comments

Comments
 (0)