-
Notifications
You must be signed in to change notification settings - Fork 0
[Refactor] DateFormatterHelper 구현 및 기존 코드 리팩토링 #314
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
Conversation
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.
Pull Request Overview
This PR refactors date formatting across the codebase by introducing a centralized DateFormatterHelper utility class and a DateFormatType enum to standardize date format usage and improve memory efficiency through formatter caching.
Key changes:
- Created
DateFormatterHelperwith cachedDateFormatterinstances to avoid repeated object creation - Defined
DateFormatTypeenum with six common date format patterns - Replaced all inline
DateFormatterinstantiations across mappers, view models, and views with calls to the helper
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
Wable-iOS/Core/DateFormatter/DateFormatterHelper.swift |
New helper class providing cached, reusable DateFormatter instances with thread-safe access |
Wable-iOS/Core/DateFormatter/DateFormatType.swift |
New enum defining standardized date format patterns used throughout the app |
Wable-iOS/Data/Mapper/ProfileMapper.swift |
Refactored to use DateFormatterHelper for parsing account creation date |
Wable-iOS/Data/Mapper/NotificationMapper.swift |
Refactored to use DateFormatterHelper for parsing notification timestamps |
Wable-iOS/Data/Mapper/InformationMapper.swift |
Refactored to use DateFormatterHelper for parsing game schedules, news, notices, and curation dates |
Wable-iOS/Data/Mapper/ContentMapper.swift |
Refactored to use DateFormatterHelper for parsing content timestamps |
Wable-iOS/Data/Mapper/CommentMapper.swift |
Refactored to use DateFormatterHelper for parsing comment timestamps |
Wable-iOS/Presentation/Profile/AccountInfo/ViewModel/AccountInfoViewModel.swift |
Refactored date formatting in view model |
Wable-iOS/Presentation/WableComponent/View/PostUserInfoView.swift |
Refactored date display for Korean date format |
Wable-iOS/Presentation/Overview/GameSchedule/View/GameScheduleListViewController.swift |
Refactored time-only formatting for game schedules |
Wable-iOS.xcodeproj/project.pbxproj |
Added new source files to Xcode project |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
JinUng41
left a comment
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.
NSCache를 사용하셨네요.
메모리 절약을 위한 캐싱 처리가 인상깊습니다.
저는 해당 상황에서 딕셔너리로 구현했을 것 같네요. ([열거형: 객체])
NSCache를 사용하신 이유, 그리고 어떠한 특징을 가지고 있는지 들어보고 싶어요.
코멘트도 하나 남겨두었으니 고려해 보셔도 좋을 것 같습니다.
고생하셨습니다~
| private extension DateFormatterHelper { | ||
| private static func getFormatter(for type: DateFormatType) -> DateFormatter { | ||
| let key = type.rawValue as NSString | ||
|
|
||
| if let cached = formatterCache.object(forKey: key) { | ||
| return cached | ||
| } | ||
|
|
||
| let formatter = DateFormatter() | ||
| formatter.dateFormat = type.rawValue | ||
| formatter.locale = Locale(identifier: "ko_KR") | ||
| formatter.timeZone = .current | ||
|
|
||
| formatterCache.setObject(formatter, forKey: key) | ||
| return formatter | ||
| } | ||
| } |
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.
DateFormatter를 반환하는 책임을 헬퍼가 아닌 다른 객체가 하면 생성과 활용의 책임이 분리될 수 있을 것 같습니다.
디자인 패턴 중 생성 패턴을 이용해 보면 좋을 것 같아요.
이렇게 하면 인스턴스 반환만 원할 때는 해당 객체만을 이용하는 것이죠.
당장 떠오르는 것은 팩토리 패턴 혹은 추상 팩토리 패턴이 있을 수 있겠네요.
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.
간단한 로직이기도 하고 지금 수준이 딱 적당한 구현 크기라고 생각해서 책임을 나누지는 않았는데요!
해당 부분에 대해 조금 더 논의해보면 좋을 것 같아요. 현재 Core 레이어에 함께 존재하는 PhotoPickerHelper에 대해서도 이야기 나누고 싶은 부분이 있어... 회의 안건으로 건의드립니다! 리뷰 감사합니다 😊
@JinUng41 리뷰 감사합니다! 그러나
때문에 관련 대안을 찾아보았고,
물론 구현의 복잡성 때문에 좋은 의견 주셔서 감사합니다! 답변이 되었으면 좋겠는데요 ㅎㅎ 좋은 의견 또 주시면 같이 이야기해보면 좋을 것 같아요. |
네 답변 감사합니다! 고생하셨어요~ |
👻 PULL REQUEST
📄 작업 내용
DateFormatter객체 대신 사용할DateFormatterHelper를 구현했어요.DateFormatTypeenum으로 구현했어요.💻 주요 코드 설명
DateFormatType구현fullDateTime) 가독성과 재사용성을 높였습니다.DateFormatterHelper 구현
dateFormat을 하나하나 작성해주어야 했고, ISO 국제 표준에 맞게 대소문자를 구분해 작성해주어야 했기에 휴먼 에러가 발생할 수 있는 환경이었습니다. ([Fix] 게시글, 댓글 셀 뷰 Configure 되지 않는 문제 해결 #312 )Before:
After:
📚 참고자료
DateFormatter Apple Documentation
Technical Q&A QA 1480: NSDateFormatter and Internet Dates
✅ 이번 PR에서 이런 부분을 중점적으로 체크해주세요!
잠깐 확인하고 갈까요?
들여쓰기를 5번 이하로 준수했는지, 코드 가독성이 적절한지 확인해주세요.
한 줄당 120자 제한을 준수했는지 확인해주세요.
MARK 주석이 정해진 순서와 형식에 맞게 작성되었는지 확인해주세요.
반복되는 상수 값이 있는지, 있다면 Constant enum으로 분리되어 있는지 확인해주세요.
삼항 연산자가 길어질 경우 적절히 개행되어 있는지 확인해주세요.
조건문에서 중괄호가 올바르게 사용되었는지 확인해주세요.
라이브러리 import가 퍼스트파티와 서드파티로 구분되고 알파벳순으로 정렬되었는지 확인해주세요.
용량이 큰 리소스나 호출되지 않을 가능성이 있는 프로퍼티에 lazy var가 적절히 사용되었는지 확인해주세요.
메모리 누수 방지를 위한 weak 참조가 필요한 곳에 적용되었는지 확인해주세요.
도메인 로직과 UI 로직이 적절히 분리되어 있는지 확인해주세요.
🔗 연결된 이슈