Skip to content
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

[Refactor]: 패키지 분리 #97

Open
wants to merge 1 commit into
base: albertimkr
Choose a base branch
from

Conversation

AlbertImKr
Copy link
Collaborator

수정사항

  • 원인: 코드가 한 페키지에 모두 들어가 있어서 관리가 어려움이 있었습니다.
  • 해결: Layer 별로 패키지를 분리하여 관리하기 쉽게 하였습니다.

Comment on lines +12 to +19
interface UrlShortenService {

fun getOriginUrl(request: ShortenUrlSearchRequest): OriginUrlResponse
fun saveShortenUrl(request: ShortenUrlCreateRequest): ShortenedUrlResponse
}

@Service
class DefaultUrlShortenService(private val shortenedUrlRepository: ShortenedUrlRepository) : UrlShortenService {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service 구현체를 한 파일에서 관리하도록 변경했어요.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

구현체의 종류가 늘어나면 어떻게 하실 생각인가요?

@@ -1,4 +1,4 @@
package community.whatever.onembackendkotlin
package community.whatever.onembackendkotlin.common.dto
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dto를 매 계층마다 관리할 수 있지만 복잡한 프로젝트가 아니라서 코드의 격리보다 코드의 복잡성 증가를 방지하기 위해 Common 패키지에 Dto를 모아두었어요.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlbertImKr AlbertImKr requested a review from Hyune-c March 7, 2025 00:44
Comment on lines +12 to +19
interface UrlShortenService {

fun getOriginUrl(request: ShortenUrlSearchRequest): OriginUrlResponse
fun saveShortenUrl(request: ShortenUrlCreateRequest): ShortenedUrlResponse
}

@Service
class DefaultUrlShortenService(private val shortenedUrlRepository: ShortenedUrlRepository) : UrlShortenService {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

구현체의 종류가 늘어나면 어떻게 하실 생각인가요?

if (shortenedUrlRepository.existsByOriginUrl(originUrl)) {
return ShortenedUrlResponse(shortenedUrlRepository.findByOriginUrl(originUrl)!!.id!!)
}
return ShortenedUrlResponse(shortenedUrlRepository.save(ShortenedUrl(originUrl)).id!!)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!! 는 지양해야 됩니다.

@@ -1,4 +1,4 @@
package community.whatever.onembackendkotlin
package community.whatever.onembackendkotlin.common.dto
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1,4 +1,4 @@
package community.whatever.onembackendkotlin
package community.whatever.onembackendkotlin.common.exception

const val URL_NOT_FOUND_MESSAGE = "해당 키에 대한 URL이 존재하지 않습니다."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exception 안에 있고 밖에 있고의 차이가 무엇일까요?

  • nit 저는 top-level 에 무엇이 있는 것을 선호하지 않지 않습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants