Backwardly Compatible Code (Activity)
Title | Backwardly Compatible Code |
Overview | The learner will examine the code for the Color class from the Java API and make determinations about its content and why it was designed as it was |
Prerequisite Knowledge | Mid-level CS1 to beginning CS2 language skill sets, including basic javadoc |
Learning Objectives | The learner should be able to understand code, read javadoc comments, infer the coding standards used, and understand how backward compatibility can be supported after the activity. |
Background:
The rationale of the activity is to provide an example in which a class was not correctly written when it was first published. The Color class source code in Java SE provides an example in which the code was updated in version 1.4 to correctly support coding standards, but the code is still backwardly compatible for application written using the class in version 1 through 1.3.
Directions:
- Even Experts Make Mistakes
- You can download the source code for the Java classes in Java SE. Where is the source code located?
- Find the Color class for Java 7. Read and understand the code.
- Answer the following questions from the code:
- What does the first 20 or so lines contain?
- When was the Color class written?
- Who are the author/s?
- What is sRGB?
- What interface/s does the Color class implement?
- How many public instance variables are contained in the Color class? What are the name/s of the instance variables?
- How many public static variables are contained in the Color class? List the variables that are have a constant value. What is the naming standard for constants in Java 7?
- How many private instance variables are contained in the class?
- How many private static variables are contained in the class?
- Go to the Java API for the Color class. Can you find any reference to the instance variable named falpha? Why or why not? Find falpha in the java code. Does the code tell you what the falpha variable does?
- Are there any private methods? What do these method/s do? Are the comments sufficient?
- It seems like each color is defined twice (such as RED and red). What version implemented the uppercase name of the color?
- Thought questions about the code:
- Why do you think there are two “versions” (that are the same, except for the name) of each color? What happened?
- After the uppercase version of the Color was created, why didn’t the authors just delete the lowercase version?
- Do you think there were probably lots of lines of Java code in production as of version 1.4? Would it have been wise to just drop support of the colors written using names in camel case?
- Define backward compatibility. How does the Color class demonstrate the concept of backward compatibility?
Deliverables:
A document that contains the answers to each of the questions.
Assessment:
How will the activity be graded?
How will learning will be measured?
Include sample assessment questions/rubrics.
Comments:
What should the instructor know before using this activity?
What are some likely difficulties that an instructor may encounter using this activity?
Additional Information:
Knowledge Area/Knowledge Unit | What ACM Computing Curricula 2013 https://www.acm.org/education/CS2013-final-report.pdf knowledge area and units does this activity cover? |
Topic | What specific topics are addressed? The Computing Curriucula 2013 provides a list of topics - https://www.acm.org/education/CS2013-final-report.pdf |
Level of Difficulty | Is this activity easy, medium or challenging? |
Estimated Time to Completion | How long should it take for the student to complete the activity? |
Materials/Environment | What does the student need? Internet access, IRC client, Git Hub account, LINUX machine, etc.? |
Author | Who wrote this activity? |
Source | Is there another activity on which this activity is based? If so, please provide a link to the original resource. |
License | Under which license is this material made available? (http://creativecommons.org/licenses/) |
Suggestions for the Open Source Project:
Suggestions for an open source community member who is working in conjunction with the instructor.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License