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

[refact/clean] : LoveViewModel 클린아키텍처 마이그레이션 #107

Merged
merged 13 commits into from
May 10, 2023

Conversation

SsongSik
Copy link
Member

@SsongSik SsongSik commented May 6, 2023

주요 작업 내용

작업 내용 정리

  • 찜꽁리스트 Room 에 저장하는 로직을 클린아키텍처로 적용

변경점

  • LoveViewModel이 insertFoodDataUseCase를 참조, LoveRepository 생성
  • LoveViewModel 에 있는 insert, delete, 조회, 페이징 조회 완료

Notice

  • 이 구조로 가는것이 괜찮은지 한 번 봐주시고, 괜찮으면 이대로 마이그레이션 진행하도록 하겠습니다.

Copy link
Contributor

@kez-lab kez-lab 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 3 to 17
data class InsertFoodEntity(
val address_name: String,
val category_group_code: String,
val category_group_name: String,
val category_name: String,
val distance: String,
val id: String,
val phone: String,
val place_name: String,
val place_url: String,
val road_address_name: String,
val x: String,
val y: String
)

Copy link
Contributor

Choose a reason for hiding this comment

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

해당 변수들은 camelCase로 작성하는게 더 좋아보일 것 같습니다!!

Copy link
Member Author

Choose a reason for hiding this comment

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

네넵!!

Comment on lines 6 to 8

suspend fun insertFood(insertFoodEntity: InsertFoodEntity)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

함수 네이밍을 바꿔야할 것 같아요!! 동작과 완전 상이한 네이밍이여서 헷갈릴 것 같습니다

Copy link
Member Author

Choose a reason for hiding this comment

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

좋습니다!

Comment on lines +1 to 4
package com.myongsik.myongsikandroid.domain.model.user

data class ResponseUserEntity(
val httpCode: Int,
Copy link
Contributor

Choose a reason for hiding this comment

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

user로 세분화 해두신 것 너무 감사합니다!

Comment on lines 1 to 5
package com.myongsik.myongsikandroid.domain.usecase.love

interface LoveCase {

}
Copy link
Contributor

Choose a reason for hiding this comment

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

-GPT 왈-

안드로이드 앱에서 Use Case는 앱의 비즈니스 로직을 구현하는 데 사용되는 중요한 개념입니다. Use Case는 일반적으로 다음과 같은 기능을 수행합니다.

사용자의 요구사항을 처리하기 위한 액션을 정의합니다.
하나 이상의 리포지토리(repository)를 사용하여 데이터를 읽고 쓰는 로직을 구현합니다.
적절한 비즈니스 로직을 수행하여 결과를 반환합니다.
Use Case는 단일 책임 원칙(Single Responsibility Principle)에 따라 하나의 일만 수행하도록 설계되어야 합니다. 또한, Use Case는 SOLID 원칙에 따라 인터페이스 추상화를 사용하여 느슨한 결합을 유지해야 합니다.

이러한 이유로 Use Case를 인터페이스로 정의하고, 각 Use Case에 해당하는 구체적인 기능을 internal 클래스로 구현하여 사용합니다. 이렇게 하면 앱의 코드를 더욱 모듈화하고, 코드의 재사용성과 유지보수성을 높일 수 있습니다.

또한, Use Case를 인터페이스로 정의하면 의존성 주입(Dependency Injection)과 같은 기술을 사용하여 다양한 구현체를 주입할 수 있습니다. 이를 통해 앱의 테스트 용이성과 확장성을 높일 수 있습니다.

따라서 Use Case를 인터페이스로 정의하고, internal 클래스로 구현하는 것은 좋은 앱 아키텍처를 구현하기 위한 중요한 구성 요소입니다.

위와 같은 이유로 class경우에는 internal로 선언하는 것이 좋다고는 하네요 일단 저도 바꾸어놓겠습니다 일단 UseCase interface같은 경우에는 제가 만들어둔 UseCase만을 결합하여 사용하시면 될 것 같아용

@SsongSik SsongSik changed the title [refact/clean] : 찜꽁리스트 저장 클린아키텍처 적용 [refact/clean] : 클린아키텍처 마이그레이션 May 9, 2023
@SsongSik SsongSik changed the title [refact/clean] : 클린아키텍처 마이그레이션 [refact/clean] : LoveViewModel 클린아키텍처 마이그레이션 May 9, 2023
@SsongSik SsongSik merged commit f6f443e into main May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants