CamelCase conversion to friendly name, i.e. Enum constants; Problems?

前端 未结 3 1865
小蘑菇
小蘑菇 2021-01-13 03:48

In my answer to this question, I mentioned that we used UpperCamelCase parsing to get a description of an enum constant not decorated with a Description attribute, but it wa

3条回答
  •  孤街浪徒
    2021-01-13 04:04

    Let's say every case you come across works with this (you're asking us for examples that won't and then giving us some, so you don't even have a question left).

    This still binds UI to programmatic identifiers in a way that will make both programming and UI changes brittle.

    It still assumes your program will only be used in one language. Either your potential market it so small that just indexing an array of names would be scalable enough (e.g. a one-client bespoke or in-house project), or you are assuming you will never be successful enough to need to be available to other languages or other dialects of your first-chosen language.

    Does "well, it'll work as long as we're a failure" sound like a passing grade in balancing designs?

    Either code it to use resources, or else code it to pass the enum name blindly or use an array of names, as that at least will be modifiable afterwards.

提交回复
热议问题