diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-01-13 13:16:06 +0100 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-01-13 13:16:06 +0100 |
commit | 9232b8d817d4cd4122947375156fa2fa1e9fba14 (patch) | |
tree | e4feb77f2e508f008b78f722e91488bb9a3f3806 /zettelkast/Notes/290220240843 - Value Object.md | |
parent | ed0753ad224f0c65133bd7a63180257eecd9f5e3 (diff) |
vault backup: 2025-01-13 13:16:06
Diffstat (limited to 'zettelkast/Notes/290220240843 - Value Object.md')
-rw-r--r-- | zettelkast/Notes/290220240843 - Value Object.md | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/zettelkast/Notes/290220240843 - Value Object.md b/zettelkast/Notes/290220240843 - Value Object.md deleted file mode 100644 index 10a9afa..0000000 --- a/zettelkast/Notes/290220240843 - Value Object.md +++ /dev/null @@ -1,15 +0,0 @@ -A Value Object is a domain object that has no unique identity but if any of its properties change it is no longer the same. An example can be made with money. - -```py -from dataclasses import dataclass - -@dataclass(frozen=True) -class Money: - type: str - value: int - -Money("Euro", 10) != Money("Euro", 9) -Money("GBP", 10) != Money("Euro", 10) -``` - -Thus such an object is a perfect candidate for immutability. With python we can add @dataclass(frozen=True). Frozen=true makes it immutable.
\ No newline at end of file |