“Groovy bashers” – Everyone doesn’t have to like a language Sun sounding like Microsoft: Commodities, Railroads and How Sun Monetizes Java
Jul 18

Cardinality right in your programming language

Tech Add comments

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? :)

One Response to “Cardinality right in your programming language”

  1. James Strachan Says:

    I’m very tempted :). Lets fix the core language first then add this to the pile of features to add for version 2 :)

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: What is the number before 3? (just put in the digit)

Loading...