zoukankan      html  css  js  c++  java
  • JXSE 2.5 : What's Cool #4 Generics & enums

    http://weblogs.java.net/blog/bondolo/archive/2007/09/jxse_25_whats_c_3.html

    ————————————————————————————————————————————————————————————

    JXSE 2.5 : What's Cool #4 -- Generics & enums

    Posted by bondolo on September 13, 2007 at 5:54 PM EDT
    JXSE (JXTA for Java SE/EE 5.0) 2.5 contains quite a number of exciting changes for JXTA application developers. This little series will look at a few of the important changes in the upcoming release.

    JXSE 2.4 was the first version to require Java Standard Edition 5.0. For that release we used only a small amount of JSE 5 specific functionality. The requirement of JSE 5.0 was primarily about advancing the support matrix to include the then newly released JSE 6 and providing the opportunity to take advantage of new features in future releases. In JXSE 2.4.1 we started to make much greater use of JSE 5.0 specific features. The most obvious examples are the use of Java Generics and Enums. In JXSE 2.5 we have continued to make greater use of both of these features and each are now used extensively through out the JXSE source. These two features have allowed us to greatly simplify and clarify the JXSE APIs and implementation.

    The common case for Java generics involves being able to write type-safe algorithms which can be applied to any appropriate data-type. The most popular usage of generics is undoubtedly the Java SE Collection utilities. In JXSE 2.5 we have converted virtually all of our usage of the collection classes to make use of the generified versions. For example, where a JXSE API previously returned Vector it now likely that it will return Vector. According to Java language rules programs which reference the "raw" Vector type will continue to work.

    There are several advantages to the genericized API. The contents of the result Vector are now explicit which makes the API clearer. This is the primary advantage. An obvious API is one which will be used correctly. Programs which use the API can also more easily avoid errors because they can be written with direct reference to the correct types. We've been able to find errors even within JXSE itself where the wrong type was being used. If you have been using older versions of JXSE we think you'll find using the updated versions of the APIs much more convenient and pleasing to use, especially if you use an IDE with code completion.

    JXSE 2.5's use of enums is designed to be compile time compatible in all cases with previous versions of JXSE. Unfortunately, for internal language support reasons, programs which were compiled against 2.4.1 or earlier must be recompiled to use JXSE 2.5. The JXSE libraries have always tried to maintain version-to-version compile-time compatibility though, such as in the case of the conversion to use enum, it has not always been possible to maintain runtime compatibility. The primary advantages of using enum within JXSE has been to improve clarity and simply usage as well as to take advantage of enum properties such as the ability to use switch statements for enum typed variables.

     
  • 相关阅读:
    NOIP2015 斗地主
    BZOJ 2120: 数颜色
    BZOJ 1014: [JSOI2008]火星人prefix
    BZOJ 4665: 小w的喜糖
    BZOJ 3665: maths
    BZOJ 3270: 博物馆
    BZOJ 1419: Red is good
    【转】二分图的最大匹配
    POJ 3026 Borg Maze(Prim+BFS建邻接矩阵)
    POJ 2485 Highway(Prim+邻接矩阵)
  • 原文地址:https://www.cnblogs.com/cuizhf/p/2222249.html
Copyright © 2011-2022 走看看