chore: add test oopp learning project structure
This commit is contained in:
parent
fae4b5870e
commit
86bfb9084a
13 changed files with 661 additions and 0 deletions
51
cse1105-oopp/doc/CSE1105.md
Normal file
51
cse1105-oopp/doc/CSE1105.md
Normal file
|
@ -0,0 +1,51 @@
|
|||
# CSE 1105 Collaborative Software Engineering Project
|
||||
|
||||
## Dependency Injection
|
||||
|
||||
> **Dependent-on components** not managed by the component anymore, but need to be provided (injected) from outside.
|
||||
|
||||
### Dependency Inversion Principle
|
||||
|
||||
Traditional Control Flow:
|
||||
|
||||
- App calls/uses Library
|
||||
|
||||
Inverted Control Flow:
|
||||
|
||||
- App calls interface
|
||||
- the Library implements the interface
|
||||
|
||||
The high-level code no longer depends on the low-level code, both depend on abstractions.
|
||||
|
||||
For example:
|
||||
|
||||
```java
|
||||
public interface RailObject {
|
||||
boolean isRunning();
|
||||
|
||||
void setDestination(String destinationName);
|
||||
|
||||
Duration getRunningTime();
|
||||
}
|
||||
|
||||
public interface RailController {
|
||||
private RailObject[] objects;
|
||||
|
||||
public RailController(RailObject[] objects) {
|
||||
this.objects = objects;
|
||||
}
|
||||
|
||||
public void setAllDestinations(StationDataSet stops) {
|
||||
for (RailObject object : objects) {
|
||||
// sommige dingen doen
|
||||
...
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Here, a `RailObject` can be implemented by any class, as long as they provide the right interface methods, `isRunning`, `setDestination`, `getRunningTime`. This decouples `RailController` from a specific implementation of `RailObject`, like `Train`, such that the controller can be used for more objects.
|
||||
|
||||
## JavaFX
|
||||
|
||||
## Spring Boot
|
Loading…
Add table
Add a link
Reference in a new issue