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

[Refactor] 스탯, 직책등 데이터 처리 #77

Open
dongcheolpark opened this issue Dec 23, 2022 · 3 comments
Open

[Refactor] 스탯, 직책등 데이터 처리 #77

dongcheolpark opened this issue Dec 23, 2022 · 3 comments
Assignees

Comments

@dongcheolpark
Copy link
Contributor

📔 작업 설명 📔

스탯과 직책등 데이터 요소들을 배열로 관리하는데 이는 다음과 같은 문제를 야기시킵니다.

  1. 스탯의 이름 관리가 복잡해집니다.
    private string MakeResultText()
    {
    string result = new string("");
    for(int i=0; i<_event.Stat.Length; i++)
    {
    if (_event.Stat[i] == 0)
    continue;
    if(_event.Stat[i] > 0)
    result += $"{Enum.GetName(typeof(Define.StatKor), i)}이(가) {_event.Stat[i]} 증가했습니다.\n";
    else
    result += $"{Enum.GetName(typeof(Define.StatKor), i)}이(가) {-_event.Stat[i]} 감소했습니다.\n";
    }
    return result;
    }
    }

    위 코드에서는 스탯의 이름을 Enum.getname함수를 통해 가져오고 있습니다. 가져올 때 Enum의 Pos값이 필요하기에 Foreach등을 사용할 수 없어 코드가 알아보기 힘들어지고 복잡해집니다.
  2. 중복 코드가 다수 발생할 수 있습니다.
  3. 다른 데이터 요소가 추가되게 되면 수정에 어려움이 발생할 수 있습니다.
    직책이 추가, 삭제 되었을 때 배열을 사용하면 순서에 의존적이고 중복 코드가 많은 현재 코드는 이를 다루기 어렵습니다.

따라서 데이터를 처리할 Wrapper 클래스가 필요합니다. Wrapper 클래스에는 다음과 같은 요소가 포함되어야 합니다.

  1. 배열로 처리하는 대신 Dictionary로 처리
  2. Iterator 혹은 IEnumerable등으로 데이터 리턴
@dongcheolpark
Copy link
Contributor Author

동의하시면 작업해보겠습니다

@dongcheolpark dongcheolpark changed the title [Refactor] 스탯, 직책등 Enum 처리 [Refactor] 스탯, 직책등 데이터 처리 Dec 23, 2022
@Yeogiwon
Copy link
Contributor

늦어서 미안해요 저는 동의하고 채영이도 보고서 동의하면 댓글 추가해주세요

@ch-0012
Copy link
Contributor

ch-0012 commented Jan 3, 2023

확인이 늦었네요 ㅠ 해당 방향으로 작업하는 게 좋을 것 같아요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants