Skip to content

Commit b972939

Browse files
Merge pull request #221 from ibi-group/upstream-merge-2024-09-04
Upstream merge 2024-09-04
2 parents 6a41078 + 470ba17 commit b972939

File tree

216 files changed

+2110
-977
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+2110
-977
lines changed

.github/pull_request_template.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Write a few words on how the new code is tested.
4747
- Was the code designed so it is unit testable?
4848
- Were any tests applied to the smallest appropriate unit?
4949
- Do all tests
50-
pass [the continuous integration service](https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/docs/Developers-Guide.md#continuous-integration)
50+
pass [the continuous integration service](https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/doc/user/Developers-Guide.md#continuous-integration)
5151
?
5252

5353
### Documentation
@@ -59,7 +59,7 @@ Write a few words on how the new code is tested.
5959

6060
### Changelog
6161

62-
The [changelog file](https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/docs/Changelog.md)
62+
The [changelog file](https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/doc/user/Changelog.md)
6363
is generated from the pull-request title, make sure the title describe the feature or issue fixed.
6464
To exclude the PR from the changelog add the label `skip changelog` to the PR.
6565

.github/workflows/cibuild.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
if: github.event_name == 'pull_request'
152152

153153
- name: Install Python dependencies
154-
run: pip install -r docs/requirements.txt
154+
run: pip install -r doc/user/requirements.txt
155155

156156

157157
- name: Build main documentation

.github/workflows/post-merge.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
run: |
3030
# add a line above the one which contains AUTOMATIC_CHANGELOG_PLACEHOLDER
3131
ITEM="${TITLE} [#${NUMBER}](${URL})"
32-
TEMP_FILE=docs/Changelog.generated.md
33-
FILE=docs/Changelog.md
32+
TEMP_FILE=doc/user/Changelog.generated.md
33+
FILE=doc/user/Changelog.md
3434
awk "/CHANGELOG_PLACEHOLDER/{print \"- $ITEM\"}1" $FILE > $TEMP_FILE
3535
mv $TEMP_FILE $FILE
3636
git add $FILE

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ o_o_standalone_config_IncludeFileDirectiveTest_part.json
3030
_site/
3131
build/
3232
dist/
33-
docs/_build/
33+
doc/user/_build/
3434
gen-java/
3535
gen-javabean/
3636
gen-py/

ARCHITECTURE.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
11
# OTP Architecture
22

3-
OTP is developed over more than 10 years, and most of the design documentation is in the code as
3+
OTP has been developed for more than 15 years, and most of the design documentation is in the code as
44
comments and JavaDoc. Over the years the complexity have increased, and the natural developer
55
turnover creates a demand for more architecture and design documentation. The new OTP2 documentation
66
is put together with the source; hopefully making it easier to maintain. Instead of documenting
77
modules in old style _package-info.java_ files we use _package.md_ files. This document should serve
88
as an index to all existing top-level documented components.
99

10-
This document is far from complete - hopefully it can evolve over time and become a good
10+
This document is far from complete. Hopefully it can evolve over time and become a good
1111
introduction to OTP architecture. The OTP project GitHub issues are a good place to look for
1212
detailed discussions on many design decisions.
1313

14-
Be sure to also read the [developer documentation](docs/Developers-Guide.md).
14+
We document [Decision Records](DEVELOPMENT_DECISION_RECORDS.md) in a log. Make sure you as a developer are familiar
15+
with the decisions and follow them. Reviewers should use them actively when reviewing code and may
16+
use them to ask for changes.
17+
18+
Be sure to also read the [developer documentation](doc/user/Developers-Guide.md).
1519

1620
## Modules/Components
1721

1822
The diagram shows a simplified/generic version on how we want to model the OTP components with 2
1923
examples. The Transit model is more complex than the VehiclePosition model.
2024

21-
![MainModelOverview](docs/images/ServiceModelOverview.png)
25+
![MainModelOverview](doc/dev/images/ServiceModelOverview.png)
2226

2327
- `Use Case Service` A service which combine the functionality in many `Domain Services` to fulfill
2428
a use-case or set of features. It may have an api with request/response classes. These are
2529
usually stateless; Hence the `Use Case Service` does normally not have a model. The implementing
2630
class has the same name as the interface with prefix `Default`.
2731
- `Domain Model` A model which encapsulate a business area. In the drawing two examples are shown,
2832
the `transit` and `vhicleposition` domain model. The transit model is more complex so the
29-
implementation have a separate `Service` and `Repository`. Almost all http endpoints are ,
33+
implementation has a separate `Service` and `Repository`. Almost all http endpoints are,
3034
read-only so the `Service` can focus on serving the http API endpoints, while the repository
3135
is used to maintain the model by the updaters.
3236

@@ -41,10 +45,6 @@ but this is a start and we would like to expand this list in the future.
4145
The Configuration module is responsible for loading and parsing OTP configuration files and map them
4246
into Plan Old Java Objects (POJOs). These POJOs are injected into the other components.
4347

44-
### [REST API](src/main/java/org/opentripplanner/api/package.md)
45-
46-
Short introduction to the REST API.
47-
4848
### [GTFS import module](src/main/java/org/opentripplanner/gtfs/package.md)
4949

5050
Used to import GTFS transit data files.

DEVELOPMENT_DECISION_RECORDS.md

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Development Decision Records
2+
3+
4+
## Use-Decision-Records
5+
6+
We will [use decision-records](doc/dev/decisionrecords/UseDecisionRecords.md) to document OTP
7+
development relevant decision. Use the [template](doc/dev/decisionrecords/_TEMPLATE.md) to describe
8+
new decision records.
9+
10+
11+
## Scout-Rule
12+
13+
Leave things BETTER than you found them, clean up code you visit or/and add unit
14+
tests. Expect to include some code cleanup as part of all PRs.
15+
16+
## Follow-Naming-Conventions
17+
18+
Use established terminology from GTFS, NeTEx or the existing OTP code. Make sure the code is easy
19+
to read and understand. [Follow naming conventions](CODE_CONVENTIONS.md#naming-conventions) .
20+
21+
22+
## Write-Code-Documentation - Use JavaDoc
23+
24+
Document the business intention and decisions in the relevant code. Do not repeat the logic
25+
expressed in the code. Use JavaDoc, you may have to refactor part of your code to encapsulate the
26+
business logic into a method or class to do this.
27+
28+
Document all `public` types, methods and fields with JavaDoc. It is ok to document implementation
29+
notes on `private` members and as inline comments.
30+
31+
> If you decide to NOT follow these decision records, then you must document why.
32+
33+
**See also**
34+
- [Developers-Guide > Code comments](doc/user/Developers-Guide.md#code-comments).
35+
- [Codestyle > Javadoc Guidlines](doc/dev/decisionrecords/Codestyle.md#javadoc-guidlines) - JavaDoc checklist
36+
37+
38+
## Document-Config-and-APIs
39+
40+
Document API and configuration parameters.
41+
42+
43+
## Respect-Codestyle
44+
45+
OTP uses prettier to format code. For more information on code style see the
46+
[Codestyle](doc/dev/decisionrecords/Codestyle.md) document.
47+
48+
49+
## Use-Object-Oriented-Principals
50+
51+
Respect Object-Oriented principals
52+
- Honor encapsulation & Single-responsibility principle
53+
- Abstraction - Use interfaces when a module needs "someone" to play a role
54+
- Inheritance - Inheritances expresses “is-a” and/or “has-a” relationship, do not use it "just"
55+
to share data/functionality.
56+
- Use polymorphism and not `instanceof`.
57+
58+
59+
## Use-Dependency-Injection
60+
61+
Use dependency injection to wire components. You can use manual DI or Dagger. Put the
62+
wiring code in `<module-name>/configure/<Module-name>Module.java`.
63+
64+
OTP will use a dependency injection library or framework to handle object lifecycles (particularly
65+
request-scoped vs. singleton scoped) and ensure selective availability of components, services,
66+
context, and configuration at their site of use. Systems that operate via imperative Java code
67+
(whether hand-written or generated) will be preferred over those operating through reflection or
68+
external markup files. See [additional background](https://github.com/opentripplanner/OpenTripPlanner/pull/5360#issuecomment-1910134299).
69+
70+
## Use-Module-Encapsulation
71+
72+
Keep modules clean. Consider adding an `api`, `spi` and mapping code to
73+
isolate the module from the rest of the code. Avoid circular dependencies between modules.
74+
75+
76+
## DRY - Do not repeat yourself
77+
78+
Keep the code [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) - Do not
79+
repeat yourself. Avoid implementing the same business rule in two places -> refactor.
80+
81+
82+
## Avoid-Feature-Envy
83+
84+
[Feature envy](https://refactoring.guru/smells/feature-envy)
85+
86+
87+
## Test-Coverage
88+
89+
All _business_ logic should have unit tests. Keep integration/system tests to a minimum. Add test at
90+
the lowest level practical to test the business feature. Prefer unit tests on a method over a class,
91+
over a module, over the system. On all non-trivial code, full _branch_ test coverage is preferable.
92+
Tests should be designed to genuinely demonstrate correctness or adherence to specifications, not
93+
simply inflate line coverage numbers.
94+
95+
96+
## Use-Immutable-Types
97+
98+
Prefer immutable types over mutable. Use builders where appropriate. See
99+
[Records, POJOs and Builders](doc/dev/decisionrecords/RecordsPOJOsBuilders.md#records-pojos-and-builders)
100+
101+
102+
## Be-Careful-With-Records
103+
104+
[Avoid using records if you cannot encapsulate it properly](doc/dev/decisionrecords/RecordsPOJOsBuilders.md#records)
105+
106+

0 commit comments

Comments
 (0)