Hi. I'd like to define `Entity` for domain of DDD ...
# getting-started
s
Hi. I'd like to define
Entity
for domain of DDD in Kotlin. Is my field definition correct? I use
val
for
id
because this field is immutable. And I use
var
for
name
and
status
because they are mutable fields. All fields are
private
to prevent to be updated directly from the outside.
c
You could probably use an
enum
for the status instead of a
String
.
s
I see. thank you.
m
you could also use a data class i guess
s
In my understand data class is used for
value object
. Because data class is the same as the
value object
because it is considered the same object if all the fields are the same. Data class can also be used for
Entity
?
n
OT: you guys are like a stoplight 😛
1
🤣 5
c
@speed_star
value class
is a future syntax,
data class
just means “please generate
toString
,
hashCode
and a few other convenient things (
copy
,
componentN
...)”. You can still
override
those you don't like.
👍 1
s
I got it :)
k
but with vals and @NoCopy you basically get valueobject 🙂