Skip to content

Conversation

@f7q
Copy link
Owner

@f7q f7q commented Mar 25, 2018

クラス定数として持つ場合の観点が変わってきている。

  • 従来はconst 定義でアッパースネークケースが主流。
  • DBに持たせる時代もあった。
  • 今はenum型からシングルトン的に持たせるようになってきている?

DDD本のValueObjectに類似している点として不変性を持つ、かつ多言語に応用するケースが多い。
リフレクションとアノテーションによる手段は邪道っぽいが・・・サンプルを追加。

Copy link
Owner Author

@f7q f7q left a comment

Choose a reason for hiding this comment

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

レビュー

[Fact]
public void Test3()
{
Assert.Equal("�R�{�R", this.helper.GetKbn<EnumSample>(EnumSample.KbnYamamoto));
Copy link
Owner Author

Choose a reason for hiding this comment

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

文字化け修正する。

Assert.Equal<int>(3, list.Count());
Assert.Equal("test", list.ElementAt(0).Name);
Assert.Equal("aaaa", list.ElementAt(1).Name);
Assert.Equal("�R�{�R", list.ElementAt(2).Name);
Copy link
Owner Author

Choose a reason for hiding this comment

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

文字化け

Assert.Equal("�R�{�R", list.ElementAt(2).Name);
Assert.Equal("1:test", list.ElementAt(0).IdAndName);
Assert.Equal("2:aaaa", list.ElementAt(1).IdAndName);
Assert.Equal("3:�R�{�R", list.ElementAt(2).IdAndName);
Copy link
Owner Author

Choose a reason for hiding this comment

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

文字化け

public readonly static int Kbn1 = 1;
[Enum(Name = "aaaa", IdAndName = "2:aaaa")]
public readonly static string Kbn2 = "aaaa";
[Enum(Name = "�R�{�R", IdAndName = "3:�R�{�R")]
Copy link
Owner Author

Choose a reason for hiding this comment

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

文字化け

}
}

public class EnumSample
Copy link
Owner Author

Choose a reason for hiding this comment

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

列挙定義クラスはひとつずつの方がリファクタリングしやすい

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