I think I agree with James’ thoughts on displaying cardinality in a language
(from a comment on Generic type parameter naming A.K.A Line Noise)
James
Agreed! I do find generics a little jarring on the eye – I’m not convinced of their value in Java other than as introspect-able metadata/reflection.
I prefer the X# or Comega approach of using type cardinalities in the language, which solves elegantly most peoples use of generics – type safe collections.
class Customer {
String! name
EmailAddress+ emails
PhoneNumber* telNumbers
String? comments
}which uses DTD-like type modifier postfixes. They’re a little wierd at first but they soon feel quite natural, after all we’re used to adding [] as a type modifier postfix
This is a lot nicer on the eye. With Generics we are seeing different information (a List that contains type X, a Map with keys of Y and values of Z, deciding the implementation of List that you want, etc etc).
When whipping together designs (either on a piece of paper, or in a UML tool) we often use this cardinality and do the mental leap to code. Why not use the same form?
Going to add this to Groovy, James? :)
July 18th, 2004 at 11:27 pm
I’m very tempted :). Lets fix the core language first then add this to the pile of features to add for version 2 :)