Convention for Filenames of Generic Classes

后端 未结 11 1126
广开言路
广开言路 2020-12-08 00:20

I want to be able to distinguish between a generic and regular (non-generic) version of a class. Much like the .NET framework does with it\'s generic and non-generic version

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 00:39

    From the responses so far it seems there isn't a consensus.

    Using the same filename in a sub-namespace (and sub-folder) "Generics" (like System.Collecctions.Generics) is an option. But it's not always desirable to create a new namespace.

    For example, in an existing namespace with non-generic classes that are maintained for backwards compatibility, but marked with ObsoleteAttribute, it's probably better to keep the generic versions in the same namespace.

    I think a suffix is a reasonable way to go. I've adopted a convention of using the type parameters as a suffix (so: MyClassT for MyClass, or MyDictionaryKV for MyDictionary.

提交回复
热议问题