-
Notifications
You must be signed in to change notification settings - Fork 33
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
base: jieunyume
Are you sure you want to change the base?
부산대 Android_이지은 4주차 2단계(리팩토링 완료) #72
Conversation
- step2 기능 목록 작성
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.
@Test | ||
fun `지도에서_에러_발생_시_에러_메세지가_나타난다`() { // 테스트를 통과하지 않습니다.. 지도 에러를 발생시키는 부분에서 오류가 나는 것 같아요ㅠㅠ 어렵습니다... | ||
activityRule.scenario.onActivity { activity -> | ||
KakaoMapSdk.init(activity, "fakeKey"); |
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.
MapActivity 에서 이미 init 을 했는데, 한번더 하기 때문에 에러를 발생시키는 것이 아닐까 추측해봐요! 에러 메시지를 첨부해주시면 함께 볼 수 있겠네요!
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) } |
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.
그나저나 lateinit 에서 by lazy 로 지연초기화 방식을 바꾼 이유가 있을까요?
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.
lateinit var은 초기화 후에 값을 변경할 가능성이 있을 때 쓰는 것이라고 이해했습니다. 초기화 후에 값을 변경할 경우가 없어서 by lazy로 변경했습니다..!
val newLocationTitle = "New Location" | ||
val result: Long = locationLocalDataSource.addSavedLocation(newLocationTitle) | ||
assertEquals(4L, result) |
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.
테스트 코드를 작성하실 떄는 given / when / then 형식을 지켜주시는 편이 좋아요! 아래 링크를 참고해보시면 큰 도움이 되지 않을까 싶습니다!
https://medium.com/@asadleo1995/unit-testing-for-android-a-beginners-guide-f8681cba3c22
- local DB에 위치 삽입, 조회
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.
수고하셨어요 !!
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()) |
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.
이부분은 추후에 hilt 적용해보면서 의존성 주입받을 수 있도록 변경해보죠!
리팩토링
멘토님이 주신 피드백들 참고해서 리팩토링했는데 봐주시면 감사하겠습니다!
근데 테스트 코드는 아직 낯설어서 더 공부하고 수정하려고 합니다!
어려웠던 점, 느낀점
중점적으로 봐주셨으면 하는 부분