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

20250202/why-use-enum 최윤서 기술 블로그 제출 #123

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

yschoi123
Copy link

No description provided.

@yschoi123 yschoi123 changed the title 20250202/ 기술 블로그 제출 20250202/ why-use-enum 최윤서 기술 블로그 제출 Feb 5, 2025
@yschoi123 yschoi123 self-assigned this Feb 5, 2025
@yschoi123 yschoi123 changed the title 20250202/ why-use-enum 최윤서 기술 블로그 제출 20250202/why-use-enum 최윤서 기술 블로그 제출 Feb 5, 2025
Copy link

@LichKing-lee LichKing-lee left a comment

Choose a reason for hiding this comment

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

작성해주신 내용 잘 봤습니다 전반적으로 이견 없는데요 다만 재컴파일이나 컴파일 오류에 대한 부분은 무슨 의미인지 잘 모르겠어요 혹시 참고하신 자료가 있다면 알려주시면 저도 한번 봐볼게요

IVE member = IVE.WONYOUNG;
```

`enum`은 내부적으로 어떤 값이든 변경해도 클라이언트 코드에는 영향을 주지 않습니다

Choose a reason for hiding this comment

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

RAY 라는 값을 YOUJIN 으로 바꾸면 정수패턴에서 1을 3으로 바꾼거랑 같은거 아닌가요? 내부 값을 아무리 바꿔도 영향을 안준다는게 무슨 의미인지 잘 모르겠어요


public class Main {
public static void main(String[] args) {
int member = Constants.IVE_WONYOUNG; // 컴파일 오류 발생하지 않음

Choose a reason for hiding this comment

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

WONYOUNG 을 제거했는데 왜 오류가 안발생한다는거예요?

}

// 추상 메서드 선언 (각 열거값이 개별적으로 구현해야 함)
public abstract String getConcept();

Choose a reason for hiding this comment

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

이 방식 너무 좋은데, 람다가 생기면서 람다를 사용하는 방식이 더 간결해요 람다방식도 같이 소개해주시면 좋을 것 같아요

public enum Group {
  IVE(() -> "세련되고 고급스러운 컨셉"), 
  AESPA(() -> "메타버스와 AI 세계관을 활용한 컨셉");

  private Concept concept;

  Group(Concept concept) {
    this.concept = concept;
  }

  public String getConcept() {
    return this.concept.concept();
  }
}

@FunctionalInterface
public interface Concept {
  public String concept();
}

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.

2 participants