• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Java Generics Adoption: How New Features are Introduced Championed or Ignored
 

Java Generics Adoption: How New Features are Introduced Championed or Ignored

on

  • 822 views

Adding features to a programming language is a difficult prospect. Politics, committees, compatibility, and egos don’t make it any easier. And once a feature has finally made it and shipped, there ...

Adding features to a programming language is a difficult prospect. Politics, committees, compatibility, and egos don’t make it any easier. And once a feature has finally made it and shipped, there is a whole other question of how does it plays out? Did designers get it right, does adoption occur? Does the promises of the new feature actually solve the software developer’s pain? How do developers decide to use a new feature, do they plan to migrate old code, coordinate coding standards?

Statistics

Views

Total Views
822
Views on SlideShare
822
Embed Views
0

Actions

Likes
1
Downloads
14
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Casts: ugly and runtime exception
  • TODO: move “myList” decl so transition smoother
  • So what happened with generics? To find out why, let’s start at the beginnning…
  • So to investigate what happened to generics, let’s look at the claims and complaints made about generics
  • TODO mention why we think they’re true (repeatedly!)
  • Emphasize historical lookSimplify process diagram
  • Zoom size of each person for contribution amount.Put research question on topFor each question, remind what answer is
  • Some developers stubbornly used “raw” types despite adoption by others in the same project, whereas, in many projects that did use generics, there was a single developer who “championed” the use of generics, by using generics much earlier and in larger amounts than other developers.
  • Casts reduced before developers start to introduce generics.Spearman rank correlation:Only squirrel-sql had a strong correlation6 with moderate correlation.Gradual reveal, starting with one project, starting with 1 lineChange colors to be consistentMention normalization partBe sure to point out parts of graph that support what you say
  • Casts reduced before developers start to introduce generics.Spearman rank correlation:Only squirrel-sql had a strong correlation6 with moderate correlation.Gradual reveal, starting with one project, starting with 1 lineChange colors to be consistentMention normalization partBe sure to point out parts of graph that support what you say
  • Prematuregenerification.
  • Clean up, make as conclusion slide

Java Generics Adoption: How New Features are Introduced Championed or Ignored Java Generics Adoption: How New Features are Introduced Championed or Ignored Presentation Transcript

  • Java Generics Adoption
    How New Features are Introduced, Championed, or Ignored
    Chris Parnin
    Georgia Tech
    Christian Bird
    Microsoft Research
    Emerson Murphy-Hill
    North Carolina State
  • Quick refresher
    Raw Type R
    List myList= …;
    String aStringFromMyList = (String)myList.get(0);
    class List{
    Object get(int i){…}
    }
    Cast (C)
  • Quick refresher
    List myList = …;
    String aStringFromMyList = (String)myList.get(0);
    class List<T>{
    T get(int i){…}
    }
    Generic Type <T>
  • Quick refresher
    Parameterized Type <P>
    List<String> myList= …;
    String aStringFromMyList = myList.get(0);
    class List<T>{
    T get(int i){…}
    }
    static <T> T head(List<T> l){
    return l.get(0);
    };
    Generic Method <M>
  • but life is not so simple…
  • public interface Identifiable<T extends Identifier<? extends What>, What> {
    public TgetObjectID();
    public Class<? super What> type();
    }
    public interface Identifier<T> {
    public long getID();
    public Class<? super T> type();
    }
    interface X <SubjectType extends Identifiable, RelationshipType extends
    Enum<RelationshipType> & Related, ObjectType extends Identifiable>{}
     
    static class A<
    SI extends Identifier<? extends SubjectType>,
    OI extends Identifier<? extends ObjectType>,
    SubjectType extends Identifiable<SI, SubjectType>,
    RelationshipType extends Enum<RelationshipType> & Related,
    ObjectType extends Identifiable<? extends OI, ? extends ObjectType>>
    implements
    X<SubjectType, RelationshipType, ObjectType> {
    }
  • public interface Identifiable<T extends Identifier<? extends What>, What> {
    public TgetObjectID();
    public Class<? super What> type();
    }
    public interface Identifier<T> {
    public long getID();
    public Class<? super T> type();
    }
    interface X <SubjectType extends Identifiable, RelationshipType extends
    Enum<RelationshipType> & Related, ObjectType extends Identifiable>{}
     
    static class A<
    SI extends Identifier<? extends SubjectType>,
    OI extends Identifier<? extends ObjectType>,
    SubjectType extends Identifiable<SI, SubjectType>,
    RelationshipType extends Enum<RelationshipType> & Related,
    ObjectType extends Identifiable<? extends OI, ? extends ObjectType>>
    implements
    X<SubjectType, RelationshipType, ObjectType> {
    }
    “As I sit and stare in stunned
    horror at this monster”
    "Writing generified classes is rocket science"
    “Probably more time and brainpower was spent
    fussing with generics than any other single thing”
  • why are these people so angry?
    As a community, we often don’t formally evaluate our claims after we put them out into the world.
  • Outcome
    ?
    Gosling
    Idea
    Guy Steele Debate
    Java 5
    Implement and Release
    Developer Usage
    1994
    1998
    2004
    2011
  • To investigate what happened to generics,
    let’s look at the claims and complaints made
    about generics
  • “I suspect we will see a lot of Java 5 code that continues to do things the bad old way as a result and contend with the mish-mash that results” (2005)
    – lambda the ultimate
    Did programmers adopt and use generics?
  • “There seems to be some debateover refactoring to utilize java generics within my current team … a holy war going on about what should and should not be done …” – stackoverflow
    Did programmers adopt and use generics?
    Will teammates all agree to use generics?
  • “Do you want to go back to casting-from-Object in every container access and dealing with the resulting runtime-revealed type errors?” – stackoverflow
    ClassCastExceptionsare rarely seen in bug reports!
    Caught with local testing before check-ins, etc…
    Did programmers adopt and use generics?
    Will teammates all agree to use generics?
    Does generics reduce runtime errors?
    Does generics reduce casts?
  • RQ 1 Adoption
    RQ 2
    Coordination
    RQ 3
    Casts
    Did programmers adopt and use generics?
    Will teammates all agree to use generics?
    Does generics reduce casts?
  • Study Setup
    RQ 1 Adoption
    RQ 2
    Coordination
    RQ 3
    Casts
    Lifetime of 20 open-source projects: Before and After generics.
    <P><M>(C)<T>R
    500 million LOC
    Entities of Interest Per Commit
    Database for Analysis
  • 532 developer’s generic usage?
    RQ 1 Adoption
    We use generic collections!
    RQ 2
    Coordination
    RQ 3
    Casts
    We use generics methods or classes!
    No generics!
  • Developers with higher commit frequency?
    RQ 1 Adoption
    Higher ratio of generics collection usage (42%)
    RQ 2
    Coordination
    RQ 3
    Casts
    But generic methods or classes stay about the same.
  • RQ 1 Adoption
    RQ 2
    Coordination
    RQ 3
    Casts
    Never used generics
  • RQ 1 Adoption
    RQ 2
    Coordination
    RQ 3
    Casts
    Another programmer starts contributing…
    Then a champion emerges!
    Then others follow.
    The champion even migrates old code.
  • RQ 1 Adoption
    RQ 2
    Coordination
    jEdit
    RQ 3
    Casts
    Casts (normalized) should decrease with generics.
    (C)
    We found no correlationfor jEdit
    <P>
  • RQ 1 Adoption
    RQ 2
    Coordination
    jEdit
    RQ 3
    Casts
    Squirrel-SQL
    Casts reduced before developers start to introduce generics.
    (C)
    (C)
    <P>
    We found a strong correlationfor Squirrel-SQL
    <P>
  • RQ 1 Adoption
    RQ 2
    Coordination
    RQ 3
    Casts
    But, overall, only Squirrel-SQL had a strong correlation, and
    6 with moderate correlation.
  • Other findings
    Very little refactoring to generics (typically under 10%)
    Half of generics instantiated with just one type
    Generics support modest reductions in duplication
    90% of generic usage is java.util collections
    IDE support has little relation to generic adoption date
    Generic methods are rare!
  • A Metaphor
    Regulates Drugs
    Regulates Programming Features
    Monitors Adverse Reactions
    Monitors Allergic Reactions
    Measures treatment effectiveness
    Measures impact and migration costs