File Names for Generic Classes

By Michael Flanakin @ 4:34 AM :: 2101 Views :: .NET, Java, Development, Patterns & Practices :: Digg it!

I'm pretty big on the practice of naming a file after the class it contains. And, yes, I follow the one class per file practice. Ever since .NET 2.0, tho, generics have thrown a kink in the system. We can't have file names with angle brackets (< and >). So, what is the best practice for naming generic class files? Java has the same problem -- perhaps more so since their file names have to be the same as their classes (a restriction I wish .NET had). I haven't touched Java since before generics were introduced, so I'm not sure how it implements that. I'd be interested in seeing, tho. I may have to give that a look at some point. Until then, I started using brackets ([ and ]) to represent generic class file names. For instance, I created a model-view-presenter (MVP) class that extends Control with a signature of Control<TView,TPresenter> and a filename of Control[TView,TPresenter]. That works, of course, but I'm wondering if there's a better way.

On a side, but perhaps related note, GhostDoc will document a generic class/member by HTML encoding the angle brackets; however, Resharper replaces them with curly braces ({ and }). I'm curious as to which is the "right" approach. If it's the latter or both, I might opt to name files with curly braces rather than brackets.