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

부산대 Android_이지은 4주차 2단계(리팩토링 완료) #72

Open
wants to merge 33 commits into
base: jieunyume
Choose a base branch
from

Conversation

JieunYume
Copy link

@JieunYume JieunYume commented Jul 19, 2024

리팩토링

  • (수정)
    멘토님이 주신 피드백들 참고해서 리팩토링했는데 봐주시면 감사하겠습니다!
    근데 테스트 코드는 아직 낯설어서 더 공부하고 수정하려고 합니다!

어려웠던 점, 느낀점

  • 테스트 코드를 따라쳐본 적은 있는데 혼자 짜려고 하니까 감이 안잡혀서 어려웠다..........

중점적으로 봐주셨으면 하는 부분

  • 카카오 지도에서 error를 발생시키는 부분을 어떻게 짜야할지 모르겠습니다!

JieunYume added 27 commits July 19, 2024 03:07
- step2 기능 목록 작성
@JieunYume JieunYume changed the base branch from main to jieunyume July 19, 2024 12:58
Copy link

@bigstark bigstark left a comment

Choose a reason for hiding this comment

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

지은님 고생 많으셨습니다!

조금 더 다음 스텝으로 나아가기 위해서는 기본적인 아키텍쳐에 대해 고민을 해보시는 것이 좋을 것 같아요. 또한 hilt 와 같은 의존성 주입을 공부해보시는 것을 추천드려요.

테스트코드, 아키텍쳐, 의존성주입 등은 서로 뗄레야 뗄 수 없는 관계에요. 시간되실 떄 한번씩 읽어보시면 좋을 것 같네요!

@Test
fun `지도에서_에러_발생_시_에러_메세지가_나타난다`() { // 테스트를 통과하지 않습니다.. 지도 에러를 발생시키는 부분에서 오류가 나는 것 같아요ㅠㅠ 어렵습니다...
activityRule.scenario.onActivity { activity ->
KakaoMapSdk.init(activity, "fakeKey");

Choose a reason for hiding this comment

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

MapActivity 에서 이미 init 을 했는데, 한번더 하기 때문에 에러를 발생시키는 것이 아닐까 추측해봐요! 에러 메시지를 첨부해주시면 함께 볼 수 있겠네요!

Comment on lines 42 to 55
private val savedLocationAdapter: SavedLocationAdapter by lazy { SavedLocationAdapter(this) }
private val savedLocationRecyclerView: RecyclerView by lazy {
findViewById(R.id.savedLocationRecyclerView)
}

private lateinit var locationDbHelper: LocationDbHelper
private lateinit var locationLocalDataSource: LocationLocalDataSource
private lateinit var locationRemoteDataSource: LocationRemoteDataSource
private lateinit var locationRepository: LocationRepository
private lateinit var savedLocationRepository: SavedLocationRepository
private val locationDbHelper: LocationDbHelper by lazy { LocationDbHelper(this) }
private val locationLocalDataSource: LocationLocalDataSource by lazy { LocationLocalDataSource(locationDbHelper) }
private val locationRemoteDataSource: LocationRemoteDataSource by lazy { LocationRemoteDataSource() }
private val locationRepository: LocationRepository by lazy { LocationRepository(locationLocalDataSource, locationRemoteDataSource) }
private val savedLocationRepository: SavedLocationRepository by lazy { SavedLocationRepository(locationLocalDataSource) }

private lateinit var clearButton: ImageView
private lateinit var searchEditText: EditText
private lateinit var noResultTextView: TextView
private val clearButton: ImageView by lazy { findViewById(R.id.clearButton) }
private val searchEditText: EditText by lazy { findViewById(R.id.SearchEditTextInMain) }
private val noResultTextView: TextView by lazy { findViewById(R.id.NoResultTextView) }

Choose a reason for hiding this comment

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

그나저나 lateinit 에서 by lazy 로 지연초기화 방식을 바꾼 이유가 있을까요?

Copy link
Author

Choose a reason for hiding this comment

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

lateinit var은 초기화 후에 값을 변경할 가능성이 있을 때 쓰는 것이라고 이해했습니다. 초기화 후에 값을 변경할 경우가 없어서 by lazy로 변경했습니다..!

Comment on lines 42 to 44
val newLocationTitle = "New Location"
val result: Long = locationLocalDataSource.addSavedLocation(newLocationTitle)
assertEquals(4L, result)

Choose a reason for hiding this comment

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

테스트 코드를 작성하실 떄는 given / when / then 형식을 지켜주시는 편이 좋아요! 아래 링크를 참고해보시면 큰 도움이 되지 않을까 싶습니다!
https://medium.com/@asadleo1995/unit-testing-for-android-a-beginners-guide-f8681cba3c22

@JieunYume JieunYume changed the title 부산대 Android_이지은 4주차 2단계 부산대 Android_이지은 4주차 2단계(리팩토링) Jul 24, 2024
@JieunYume JieunYume changed the title 부산대 Android_이지은 4주차 2단계(리팩토링) 부산대 Android_이지은 4주차 2단계(리팩토링 완료) Jul 24, 2024
Copy link

@bigstark bigstark 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 10 to 14
App.sharedPreferencesManager.putString("longitude", location.longitude.toString())
App.sharedPreferencesManager.putString("latitude", location.latitude.toString())
App.sharedPreferencesManager.putString("title", location.title.toString())
App.sharedPreferencesManager.putString("address", location.address.toString())
App.sharedPreferencesManager.putString("category", location.category.toString())

Choose a reason for hiding this comment

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

이부분은 추후에 hilt 적용해보면서 의존성 주입받을 수 있도록 변경해보죠!

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