3.1. A Better Design for Handling Enumerated Types
The Division and Conference classes represent enumerated types. Although the way these classes were developed in Chapter 2 worked well, there is a Java idiom for doing enumerated types that is superior to using integer constants. Listing 3.1 shows how this idiom (described in the following sidebar) has been applied to the Conference class; the corresponding changes have also been made to the Division class.
The Enumerated Type IdiomBasic Usage In our original application, we used static int or String types to assign constant values to several variables that collectively made up an enumerated type (we did this for Conferences, Divisions, and for the Status fields within the Team class). A superior ... |
Get J2EE™ and JAX™: Developing Web Applications and Web Services now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.