-
Notifications
You must be signed in to change notification settings - Fork 0
[✨feat] ViewCount VO 구현 #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/#42
Are you sure you want to change the base?
Conversation
- 조회수 정보를 캡슐화한 값 객체 ViewCount를 구현했습니다. - 항상 0에서 시작하며, increase() 메서드를 통해서만 상태가 변경됩니다. - 외부 값 전달은 허용하지 않고, from()을 통한 생성만 허용하여 무결성을 보장합니다. - equals, hashCode, toString 오버라이딩을 통해 VO로서의 특성을 갖추었습니다.
- from()을 통해 0으로 초기화되는 ViewCount의 생성 동작을 검증했습니다. - increase() 호출 시 값이 1 증가된 새 인스턴스가 반환되는 동작을 검증했습니다. - 외부 값 전달이 불가능한 구조이므로, 음수 예외 테스트는 포함하지 않았습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces an immutable ViewCount value object to enforce that the view count always starts at zero and only increments. It includes a factory method for initialization, an increase() method returning a new instance, and corresponding unit tests.
- Implements the ViewCount VO with immutability and negative value guarding.
- Adds unit tests verifying initial value and incrementation.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/main/kotlin/com/terning/server/kotlin/domain/internshipAnnouncement/ViewCount.kt | Implements the immutable ViewCount object with built-in invariant checks and a controlled increase() method |
src/test/kotlin/com/terning/server/kotlin/domain/internshipAnnouncement/ViewCountTest.kt | Provides unit tests validating the ViewCount initialization and increment behavior |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
완벽해서 코드리뷰 달 게 없네용..😂
정적 팩토리 메서드까지 고려하신 점 인상깊게 보고 갑니다~!
fun increase(): ViewCount = ViewCount(value + 1) | ||
|
||
companion object { | ||
private const val MIN_VALUE = 0 | ||
private const val INVALID_VIEW_COUNT_MESSAGE = "조회수는 음수일 수 없습니다." | ||
|
||
fun from(): ViewCount = ViewCount(MIN_VALUE) | ||
} | ||
|
||
override fun equals(other: Any?): Boolean = other is ViewCount && value == other.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이전 PR에서 언급은 했지만, 코드리뷰 확인해보시구 여기도 순서 맞춰주면 좋을 것 같아요!!
📄 Work Description
ViewCount
를 구현했습니다.increase()
메서드를 통해서만 값이 변경되며, 불변성을 유지합니다.💭 Thoughts
from()
만 제공하도록 제한했습니다.InternshipAnnouncement
엔티티에 적용할 예정입니다.✅ Testing Result
🗂 Related Issue