Generic blog entry

Today at work I wrote the following line of code:

private static DatedMap<String, DatedMap<String, DatedSet<DjteLog>>> projects = new DatedMap<String, DatedMap<String, DatedSet<DjteLog>>>();

I guess this means I need to do some refactoring or something?

This entry was posted in All, Computers and tagged . Bookmark the permalink.

9 Responses to Generic blog entry

  1. In C# 3.0 that would be more like:

    private static var projects = new DatedMap<String, DatedMap<String, DatedSet<DjteLog>>>();

    No refactoring needed there, right =).

    • terror_firma says:

      I don’t even know what that is.

      • There are so many things for one to be confused about there.

        • generics
        • C# 3.0 (it’s not even in pre-alpha)
        • var
        • refactoring

        I bet you could do the same thing with 50% less characters in Ruby though.

        • terror_firma says:

          I don’t even know what the original is.

          I’m assuming ‘DatedMap>>();’ is a sign of the end-times.

          • Mark Doliner says:

            It’s generics stuff. So like, ‘DatedMap’ is basically a ‘TreeMap.’ Normally you put a bunch of Objects into a TreeMap, and you index them using a different Object. But then when you call DatedMap.get(aKey) you have to cast the result to the correct data type.

            With generics in Java 1.5, when you create the DatedMap you tell the Java compiler that all the keys will be Strings and all the values will be DatedMap. Then the compiler does stricter type checking to make sure that you don’t put anything into the DatedMap that doesn’t belong there.

  2. modified says:

    Can a brother get a Java typedef?

    • Mark Doliner says:

      DatedMap is a class that extends TreeMap. DatedSet is a class that extends TreeSet. The only changes are that they keeps track of the date when the last Object was added or removed.

Leave a Reply to terror_firma Cancel reply

Your email address will not be published. Required fields are marked *