Skip to content

[#84] 모든 뷰모델에 얼리 리턴 패턴을 제거한다#147

Merged
opficdev merged 1 commit intodevelopfrom
refactor/#84-early-return-pattern
Feb 27, 2026
Merged

[#84] 모든 뷰모델에 얼리 리턴 패턴을 제거한다#147
opficdev merged 1 commit intodevelopfrom
refactor/#84-early-return-pattern

Conversation

@opficdev
Copy link
Owner

@opficdev opficdev self-assigned this Feb 27, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 Pull Request는 여러 뷰모델의 reduce 함수에서 얼리 리턴 패턴을 제거하여 코드의 일관성과 예측 가능성을 높이는 것을 목표로 합니다. SideEffect를 즉시 반환하는 대신, 모든 효과를 effects 배열에 누적한 후 함수 끝에서 한 번에 반환하도록 변경함으로써, 상태 변경 로직과 효과 발생 로직이 더 명확하게 분리되고, 잠재적인 버그를 줄이며, 향후 유지보수를 용이하게 합니다.

Highlights

  • 얼리 리턴 패턴 제거: 여러 뷰모델의 reduce 메서드에서 SideEffect를 즉시 반환하는 얼리 리턴 패턴을 제거했습니다.
  • SideEffect 수집 방식 변경: effects라는 배열을 도입하여 모든 SideEffect를 수집하고, reduce 함수 끝에서 이 배열을 한 번에 반환하도록 변경했습니다.
  • 상태 업데이트 일관성 확보: self.state = state 할당이 reduce 함수 내에서 일관되게 처리되도록 보장하여 상태 관리의 예측 가능성을 높였습니다.
Changelog
  • DevLog/Presentation/ViewModel/AccountViewModel.swift
    • reduce 메서드에서 effects 배열을 초기화하고, case 문 내에서 return 대신 effects 배열에 할당하도록 변경했습니다.
    • reduce 메서드 끝에서 effects 배열을 반환하도록 수정했습니다.
  • DevLog/Presentation/ViewModel/LoginViewModel.swift
    • reduce 메서드에서 effects 배열을 초기화하고, case 문 내에서 return 대신 effects 배열에 할당하도록 변경했습니다.
    • reduce 메서드 끝에서 effects 배열을 반환하도록 수정했습니다.
  • DevLog/Presentation/ViewModel/PushNotificationSettingsViewModel.swift
    • reduce 메서드 내 effects 배열 초기화 위치를 조정하여 일관성을 유지했습니다.
  • DevLog/Presentation/ViewModel/RootViewModel.swift
    • reduce 메서드에서 effects 배열을 초기화하고, case .signOutAuto에서 return 대신 effects 배열에 할당하도록 변경했습니다.
    • reduce 메서드 끝에서 effects 배열을 반환하도록 수정했습니다.
  • DevLog/Presentation/ViewModel/SettingViewModel.swift
    • reduce 메서드에서 stateeffects 배열을 초기화하고, case .tapDeleteAuthButtoncase .tapSignOutButton에서 return 대신 effects 배열에 할당하도록 변경했습니다.
    • reduce 메서드 끝에서 self.state = state 할당 후 effects 배열을 반환하도록 수정했습니다.
  • DevLog/Presentation/ViewModel/TodoDetailViewModel.swift
    • reduce 메서드에서 case .upsertTodo에서 return 대신 effects 배열에 할당하도록 변경했습니다.
  • DevLog/Presentation/ViewModel/TodoEditorViewModel.swift
    • reduce 메서드 내 state 변수 초기화를 추가했습니다.
    • handleStringAction 메서드 시그니처를 업데이트하여 stateinout 매개변수로 받도록 변경하고 호출부를 수정했습니다.
    • reduce 메서드 끝에서 self.state = state를 할당하도록 추가했습니다.
  • DevLog/Presentation/ViewModel/TodoManageViewModel.swift
    • reduce 메서드 내 state 변수 초기화를 추가했습니다.
    • reduce 메서드 끝에서 self.state = state를 할당하도록 추가했습니다.
Activity
  • 이 Pull Request에 대한 추가적인 활동 (댓글, 리뷰 등)은 현재 없습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

PR의 변경 사항을 검토했습니다. 모든 ViewModel의 reduce 함수에서 조기 반환(early return) 패턴을 제거하여 단일 반환 지점을 갖도록 구조를 통일했습니다. 또한, State가 구조체(struct)인 일부 ViewModel에서 상태 변경이 올바르게 반영되지 않을 수 있었던 문제를 var state = self.state 지역 변수를 사용하고 마지막에 다시 할당하는 방식으로 해결했습니다. 이를 통해 코드 전반의 일관성과 안정성이 향상되었습니다. 코드 변경 사항에 특별한 이슈는 발견되지 않았습니다.

@opficdev opficdev merged commit 4319097 into develop Feb 27, 2026
1 check passed
@opficdev opficdev deleted the refactor/#84-early-return-pattern branch February 27, 2026 01:01
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.

모든 뷰모델에 early return 금지 패턴을 적용한다

1 participant