Slide 17
Slide 17 text
ドメインモデリングのサンプル
/**
* コメント
*/
class Comment private constructor(
val id: ID,
val commentText: String,
val isResolved: Boolean,
val createdAt: DateTime,
val updatedAt: DateTime,
val createdUserId: ID,
val commentType: CommentType,
/** コメントの条件 */
val condition: CommentCondition,
) {
companion object {
fun create(
commentText: String,
createdUserId: ID,
commentType: CommentType,
condition: CommentCondition,
): Comment {
validationCommentTextLength(commentText)
val createdAt = DateTime.now()
return Comment(
id = ID.gen(),
commentText = commentText,
isResolved = false,
createdAt = createdAt,
updatedAt = createdAt,
createdUserId = createdUserId,
condition = condition,
commentType = commentType,
)
}
}
}
/**
* コメントの条件
*/
data class CommentCondition(
val departmentId: ID,
val projectId: ID,
val yearMonth: YearMonth,
)
ドメインモデル
を元に実装する
データの実例を併記しておくとわかりやすい