-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
418 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
docs/schulcloud-server/Coding-Guidelines/domain-object-validation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Domain Object Validation | ||
|
||
If you need to validate a domain object, please write an independent class, so that the domain object itself, its repo and services can reuse it. | ||
|
||
Eric Evans suggests using the specification pattern. | ||
A specification fulfills the following interface: | ||
|
||
```typescript | ||
public interface Specification<T> { | ||
boolean isSatisfiedBy(T t); | ||
} | ||
``` | ||
|
||
A specification checks if a domain object fulfills the conditions of the specification. | ||
|
||
A specification can simply specify that a domain object is valid. E.g. a `Task` has an owner and a description. | ||
A specification can specify more complex and specialized conditions. E.g. `Task` where every student assigned to the task's course has handed in a submission. | ||
|
||
The specification pattern in its full extend describes how to use logic operators to combine multiple specifications into combined specifications as well. Please don't build this as long as you don't need it. YAGNI. | ||
[More about full specification pattern](https://medium.com/@pawel_klimek/domain-driven-design-specification-pattern-82867540305c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
docs/schulcloud-server/Coding-Guidelines/img/object-ownership.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.