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

[FEAT/#10] 6주차 필수 과제 #11

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open

[FEAT/#10] 6주차 필수 과제 #11

wants to merge 18 commits into from

Conversation

yihwanggeun
Copy link
Contributor

Related issue 🛠

Work Description ✏️

  • Clean Architecture or Google Recommended Architecture 구현

Screenshot 📸

Uncompleted Tasks 😅

  • Hilt적용

To Reviewers 📢

RepositoryPool을 사용하니 클래스엮임이 더 심해진 것 같은데 이런 아키텍처에는 RepositoryPool을 적용하면 안 되는 것인가요?

object RepositoryPool {
    val hobbyRepository: HobbyRepository by lazy {
        HobbyRepositoryImpl(HobbyDataSourceImpl(ServicePool.hobbyService))
    }

    val signInRepository: SignInRepository by lazy {
        SignInRepositoryImpl(SignInDataSourceImpl(ServicePool.signInService))
    }

    val signUpRepository: SignUpRepository by lazy {
        SignUpRepositoryImpl(SignUpDataSourceImpl(ServicePool.signUpService))
    }
}

@yihwanggeun yihwanggeun added the enhancement New feature or request label Dec 6, 2024
@yihwanggeun yihwanggeun self-assigned this Dec 6, 2024
Copy link

@yskim6772 yskim6772 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 ! 시간이 된다면 DI도 적용해보면 좋을 것 같아요 ~
MVI도 화이팅 !

Comment on lines 6 to +9
@Serializable
data class BaseResponse <T> (
val status: Int,
val message: String,
val data: T? = null
@SerialName("result")
val result: T

Choose a reason for hiding this comment

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

BaseResponse 수정 굿 ~

Comment on lines 5 to 9
@Serializable
data class CreateUserResponse(
@SerialName("result")
val result: Result
) {
@Serializable
data class Result(
@SerialName("no")
val no: Int
)
} No newline at end of file
@SerialName("no")
val userId: Int

Choose a reason for hiding this comment

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

변수명도 좋네요 !

Comment on lines +11 to +23
class DefaultErrorHandler(private val context: Context) : ErrorHandler {
override fun handleNetworkError(exception: Throwable?): String {
return when (exception) {
is HttpException -> when (exception.code()) {
400 -> context.getString(R.string.network_error_400)
403 -> context.getString(R.string.network_error_403)
409 -> context.getString(R.string.network_error_409)
else -> context.getString(R.string.network_error)
}
else -> context.getString(R.string.network_error)
}
}
}

Choose a reason for hiding this comment

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

DefaultErrorHandler 좋네요
모든 API의 에러 메시지가 각 상태코드별로 서로 동일한지도 확인해보면 좋을 것 같아요 ~

Choose a reason for hiding this comment

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

에러 핸들링 함수 좋네요!!

Comment on lines +11 to +23
object RepositoryPool {
val hobbyRepository: HobbyRepository by lazy {
HobbyRepositoryImpl(HobbyDataSourceImpl(ServicePool.hobbyService))
}

val signInRepository: SignInRepository by lazy {
SignInRepositoryImpl(SignInDataSourceImpl(ServicePool.signInService))
}

val signUpRepository: SignUpRepository by lazy {
SignUpRepositoryImpl(SignUpDataSourceImpl(ServicePool.signUpService))
}
}

Choose a reason for hiding this comment

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

이런 식으로 의존성 주입 로직에 관련된 코드는, viewmodelfactory라는 이름으로 생성해줘도 될 것 같아요 ~

Choose a reason for hiding this comment

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

domain 레이어에는 다른 계층, 또는 서드파티 관련 import는 없어야한다고 알고있어용 RepositoryPool을 다른 곳으로 옮기는게 어떨까요!

@@ -0,0 +1,8 @@
package org.sopt.and.domain.repository

import org.sopt.and.core.data.dto.response.CreateUserResponse

Choose a reason for hiding this comment

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

data 레이어 관련 import가 있어서 봤더니, 이 코드에서는 안 쓰이는 import인 것 같네요! 지워줍시다 ~

import org.sopt.and.domain.entity.SignUpData

interface SignUpRepository {
suspend fun signUp(username: String, password: String, hobby: String): Result<SignUpData>

Choose a reason for hiding this comment

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

request에 들어가는 부분도, model을 하나 생성해서 써줘도 좋을 것 같아요 !

Copy link

@gitsuhyun gitsuhyun left a comment

Choose a reason for hiding this comment

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

에러 처리, 함수화 등등 전반적으로 잘 구현해주신 것 같아용 domain 레이어 부분만 신경써주시면 더 좋을 것 같습니다!! 수고하셨어요~~

Comment on lines +8 to +9
val userId: Int

Choose a reason for hiding this comment

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

요런식으로 네이밍을 다르게 할 수 있구나 처음 알았네요!

Comment on lines +11 to +23
class DefaultErrorHandler(private val context: Context) : ErrorHandler {
override fun handleNetworkError(exception: Throwable?): String {
return when (exception) {
is HttpException -> when (exception.code()) {
400 -> context.getString(R.string.network_error_400)
403 -> context.getString(R.string.network_error_403)
409 -> context.getString(R.string.network_error_409)
else -> context.getString(R.string.network_error)
}
else -> context.getString(R.string.network_error)
}
}
}

Choose a reason for hiding this comment

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

에러 핸들링 함수 좋네요!!

@@ -0,0 +1,8 @@
package org.sopt.and.domain.repository

import org.sopt.and.core.data.dto.response.GetHobbyResponse

Choose a reason for hiding this comment

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

이 부분도 안쓰는 import인 것 같아용

Comment on lines 17 to +21
class AuthViewModel(application: Application) : AndroidViewModel(application) {

private val context = getApplication<Application>().applicationContext

private val errorHandler = DefaultErrorHandler(context)

Choose a reason for hiding this comment

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

AndroidViewModel이 뭔지 찾아보니 애플리케이션 Context에 접근할 때 사용하는 거군요 굿굿!!

result.onSuccess { hobbyData ->
_uiState.value = MyPageUiState(hobby = hobbyData.hobby)
}.onFailure { e ->
_errorMessage.value = errorHandler.handleNetworkError(e)

Choose a reason for hiding this comment

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

깔끔하다!

Comment on lines +11 to +23
object RepositoryPool {
val hobbyRepository: HobbyRepository by lazy {
HobbyRepositoryImpl(HobbyDataSourceImpl(ServicePool.hobbyService))
}

val signInRepository: SignInRepository by lazy {
SignInRepositoryImpl(SignInDataSourceImpl(ServicePool.signInService))
}

val signUpRepository: SignUpRepository by lazy {
SignUpRepositoryImpl(SignUpDataSourceImpl(ServicePool.signUpService))
}
}

Choose a reason for hiding this comment

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

domain 레이어에는 다른 계층, 또는 서드파티 관련 import는 없어야한다고 알고있어용 RepositoryPool을 다른 곳으로 옮기는게 어떨까요!

Copy link
Contributor

@jihyunniiii jihyunniiii left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 ~

Comment on lines 16 to 19

class AuthViewModel(application: Application) : AndroidViewModel(application) {

private val context = getApplication<Application>().applicationContext
Copy link
Contributor

Choose a reason for hiding this comment

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

signInViewModel과 SignUpViewModel로 나누어 관리하는 것도 좋을 것 같아요! ~
(관련 내용은 합동 세미나 리뷰 페이지 참고하기!)

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

Successfully merging this pull request may close these issues.

[FEAT] WEEK6 필수 과제
4 participants