Timeline for What is the best way to structure and name files which contain generic classes with the same name?
Current License: CC BY-SA 3.0
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 7, 2015 at 23:42 | comment | added | supercat | @shylynx: If the classes are generated automatically, and should always be replaced as a unit, what advantage is there to separating each class to a different file? I would think that would simply increase the danger that someone might e.g. end up with one version of Tuple1, Tuple2, and Tuple4 but a different version of Tuple3 (e.g. because an earlier version of the project didn't need Tuple3, but a later one did, and it got fetched from a different place). | |
| Jan 16, 2015 at 15:19 | comment | added | shylynx | @RobertHarvey Name it Singleton, Pair, Triple, Quadruple, Quintuple and so on. And if you really generate the classes automatically, I would name it TupleWith1Dimension, TupleWith2Dimensions, TupleWith3Dimensions and so on. That all are short descriptive names for clean code. | |
| Jan 16, 2015 at 15:13 | comment | added | Robert Harvey | I think you're missing the point. The question asks: How do I put Tuple<T1>, Tuple<T1, T2> and Tuple<T1, T2, T3> into separate CS files in a standard way, without name clashes? | |
| Jan 16, 2015 at 15:12 | comment | added | shylynx | @RobertHarvey I wrote intent of the classes not intent of the generic parameters. | |
| Jan 16, 2015 at 15:11 | comment | added | Robert Harvey | There is no intent in generic parameters like T1, T2 and T3. Those generic parameters are deliberately intended to assume anything. How would you propose to deal with something like Tuple<T1, T2, T3, T4, T5, T6, T7, T8>? | |
| Jan 16, 2015 at 15:09 | comment | added | shylynx | @RobertHarvey To avoid such failing names I instantly recommended analysing the intend of the class to finally name the classes what the are and not how many generic parameters they have. That's why I cited the very simple classes List and Map. | |
| Jan 16, 2015 at 14:58 | comment | added | Robert Harvey | That doesn't address generic parameters that have no shape, like Tuple<T1, T2, T3>, Unless your proposal is to name it ContainerWithThreeGenericParameters.cs. It is you that is failing to read, not me. | |
| Jan 16, 2015 at 14:58 | comment | added | shylynx | @RobertHarvey Read my answer: Put one class into one file! | |
| Jan 16, 2015 at 14:54 | comment | added | shylynx | @RobertHarvey You are kiding me ;-) Put Container<Thing> into file Container.cs. Put MetricContainer<Thing, Metric> into file MetricContainer.cs and put MetricTransportableContainer<Thing, Metric, Transport> into MetricTransportableContainer.cs. Please read my last sentence carefully than you will understand that the question handles three completely different objects. | |
| Jan 16, 2015 at 14:37 | comment | added | Robert Harvey | You can't put angle brackets in a file name. | |
| Jan 16, 2015 at 14:34 | comment | added | shylynx | @RobertHarvey Please read the question carefully: classname should be aquivalent to filename. It's interchangeably. The problem lies in wrong analysis of the class and wrong naming of the generic classes in general. To sum up my answer: "Name it what it is and not what it seems to be." | |
| Jan 16, 2015 at 14:12 | comment | added | Robert Harvey | I don't think you understood the question. Look at the last paragraph of the question. | |
| Jan 16, 2015 at 10:05 | history | edited | shylynx | CC BY-SA 3.0 | lost code formatting added |
| Jan 16, 2015 at 8:21 | history | edited | shylynx | CC BY-SA 3.0 | some explanation added |
| Jan 16, 2015 at 8:12 | history | edited | shylynx | CC BY-SA 3.0 | typo removed, example added |
| Jan 16, 2015 at 8:05 | history | answered | shylynx | CC BY-SA 3.0 |