Readable Java 1.5
Subject:   Generic Syntax
Date:   2003-09-25 18:47:55
From:   anonymous2
How should your syntax work for generic types that take more than one paramter, for example Pair<A,B>?

Should it be (A,B) Pair? That looks very confusing!

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Re: Generic Syntax
    2003-09-28 08:59:29  sjungels [View]

    Sample conversation:

    Q: "How do you represent the properties in your code?"

    A: "As String, Integer pairs."

    I would argue this sounds natural to most programmers, and it corresponds to the generic syntax I proposed in the article. In general, phrases like "String list" and "String list list" are more readable than "List of String" or "List of list of String," especially for reasonable levels of nesting. Typical Java code uses generic type declarations with at most 3 or 4 levels of nesting.