[REFACTOR] 마이페이지 러닝기록 상세페이지 / 액티비티의 전역변수를 뷰모델로 이전#269
Merged
Conversation
unam98
approved these changes
Oct 28, 2023
Collaborator
There was a problem hiding this comment.
저도 최근에 다른 파일 작업하면서 같은 고민을 하고 있던 참이라 여러 사람들의 의견을 구해봤는데 아래와 같은 답변을 받았습니다.
-
변수 자체를 public으로 열고 set을 private으로 만들면 get을 만들 필요가 없어지니 코드량이 줄어들 수 있을 것이다.
-> 이 방법에 따른 장단점은 저희가 상황에 따라 직접 판단해야 할 것 같습니다. -
읽기 편하게 정리가 필요한 것이지 단순히 코드량이 많다고 가독성이 떨어지는 것은 아니다.
-
변수 스코프를 너무 넓게 잡았거나( 함수들을 묶어서 Class를 분리하든 변수를 묶어서 data class를 만들든) 코드 분리가 필요한 것일 수 있다.
-> 이 방법이 fit한 답변이라고 생각합니다. 변수 여러개로 나눠놓은 걸 하나의 data class로 묶어서 관리해도 문제가 없다고 하면 이렇게 하는 것이 코드량을 줄이는 것에 도움이 될 것 같습니다. 하지만 이렇게 하면 나중에 세밀한 핸들링이 필요한 상황에서는 유연하게 대처하기 어려워 data class를 다시 여러개의 변수로 쪼개야 하는 상황이 생길 수도 있을 것 같습니다.
제 개인적인 생각은, 일단 기존의 방법대로 계속 진행하되 "어 좀 너무 길어지는데" 싶으면 그때 위의 방법으로 상황 보고 적절한 조치를 취하면 되지 않을까 생각합니다.
Member
Author
|
자세한 답변 감사합니다!! 저도 앞으로 개발 이어나가면서 더 좋은 방식이 무엇인지 계속 고민해봐야 할 거 같습니다! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 개요
✨ 작업 내용
✨ PR 포인트
뷰모델을 이용해서 액티비티 생명주기와 무관하게 데이터들을 저장할 수 있다는 건 좋은데,
그에 따라 뷰모델에 getter, setter 관련 코드량이 증가한 것은 그닥 좋은 거 같지 않습니다..!
더 나은 방법이 있을까요?!