Backwardly Compatible Code (Activity)

From Foss2Serve
(Difference between revisions)
Jump to: navigation, search
(Directions:)
 
(23 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
{| border="1"
 
|-
 
|'''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: ===
+
{{Learning Activity Overview
 +
|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, its evolution and why its design has changed
 +
|prerequisites=
 +
Mid-level CS1 to beginning CS2 language skill sets, including basic javadoc
 +
|objectives=
 +
# Understand code, read javadoc comments, infer the coding standards used, and understand how backward compatibility can be supported after the activity.
 +
|process skills=
 +
}}
 +
 
 +
=== 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.
 
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: ===
+
=== Directions ===
#Even Experts Make Mistakes
+
##1. You can download the source code for the Java classes in Java SE. Where is the source code located?
+
##2. Find the Color class for Java 7.  Read and understand the code.
+
##3. Answer the following questions from the code:
+
###a. What does the first 20 or so lines contain?
+
###b. When was the Color class written?
+
###c. Who are the author/s?
+
###d. What is sRGB?
+
###e. What interface/s does the Color class implement?
+
###f. How many public instance variables are contained in the Color class? What are the name/s of the instance variables?
+
###g. 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?
+
###h. How many private instance variables are contained in the class?
+
###i. How many private static variables are contained in the class?
+
###j. 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?
+
###k. Are there any private methods? What do these method/s do? Are the comments sufficient?
+
###l. It seems like each color is defined twice (such as RED and red).  What version implemented the uppercase name of the color?
+
##4. Thought questions about the code:
+
###a. Why do you think there are two “versions” (that are the same, except for the name) of each color? What happened?
+
###b. After the uppercase version of the Color was created, why didn’t the authors just delete the lowercase version?
+
###c. 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?
+
###d. Define backward compatibility. How does the Color class demonstrate the concept of backward compatibility?
+
  
=== Deliverables: ===
+
# Even the Most Well-written Code Changes Over the Years
What will the student hand in?
+
##      OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java programming language.
 +
## You can download the source code for the Java classes in OpenJDK. Where is the source code located?
 +
## Find the Color class source code for Java 7.  Read and understand the code.
 +
## Answer the following questions from the code:
 +
### What does the first 20 or so lines contain? Look at the subsequent header comments. What are the tags such as @author and @version samples of?
 +
### When was this Color class written?
 +
###    Who are the author/s?
 +
### Each individual color such as red, yellow and magenta are described using a certain default standard. What is the acronym for this standard? State the words the abbreviation stands for and provide a definition 
 +
### 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 of Java 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?
 +
# Oracle makes this source code available. However, it is licensed and owned by Oracle. Therefore, can you modify this code? Is this truly open source?? 
 +
 
 +
=== Deliverables ===
 +
 
 +
A document that contains the answers to each of the questions.
 +
 
 +
=== Assessment ===
  
=== Assessment: ===
 
 
How will the activity be graded?
 
How will the activity be graded?
 
   
 
   
Line 47: Line 56:
 
Include sample assessment questions/rubrics.
 
Include sample assessment questions/rubrics.
  
=== Comments: ===
+
=== 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: ===
+
{| border="1"
+
|-
+
|'''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: ===
+
Coding standards were not originally followed when the Color class was created. The naming standard for static final variables is that they should be all uppercase, with words separated by _. To rectify this error and still allow the class to support backward compatibility for the thousands of lines of code in production already, the class now supports two names for each constant color.
Suggestions for an open source community member who is working in conjunction with the instructor.
+
  
 +
{{Learning Activity Info
 +
|acm unit=
 +
PL and SDF
 +
|acm topic=
 +
PL/Object Oriented Programming and SDF/Fundamental Programming Concepts
 +
|difficulty=
 +
Medium
 +
|time=
 +
45 minutes
 +
|environment=
 +
Access to Java 1.7 SE JDK download
 +
|author=
 +
E. Brannock
 +
|source=
 +
None
 +
|license=
 +
{{License CC BY SA}}
 +
}}
  
--------------------
+
=== Suggestions for the Open Source Project ===
This work is licensed under a
+
[http://creativecommons.org/licenses/by-sa/4.0/ Creative Commons Attribution-ShareAlike 4.0 International License]
+
  
[[File:CC_license.png]]
+
None.
  
[[Category: Learning_Activity]]
+
[[Category:Learning Activity]]
[[Category: Coding and Style]]
+
[[Category:Coding and Style]]
 +
[[Category:CS1]]
 +
[[Category:CS2]]
 +
[[Category:Good Draft]]

Latest revision as of 12:41, 5 February 2017


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, its evolution and why its design has changed

Prerequisites

Mid-level CS1 to beginning CS2 language skill sets, including basic javadoc

Learning
Objectives
After successfully completing this activity, the learner should be able to:
  1. Understand code, read javadoc comments, infer the coding standards used, and understand how backward compatibility can be supported after the activity.
Process Skills
Practiced


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

  1. Even the Most Well-written Code Changes Over the Years
    1. OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java programming language.
    2. You can download the source code for the Java classes in OpenJDK. Where is the source code located?
    3. Find the Color class source code for Java 7. Read and understand the code.
    4. Answer the following questions from the code:
      1. What does the first 20 or so lines contain? Look at the subsequent header comments. What are the tags such as @author and @version samples of?
      2. When was this Color class written?
      3. Who are the author/s?
      4. Each individual color such as red, yellow and magenta are described using a certain default standard. What is the acronym for this standard? State the words the abbreviation stands for and provide a definition
      5. What interface/s does the Color class implement?
      6. How many public instance variables are contained in the Color class? What are the name/s of the instance variables?
      7. How many public static variables are contained in the Color class?
      8. List the variables that are have a constant value. What is the naming standard for constants in Java 7?
      9. How many private instance variables are contained in the class?
      10. How many private static variables are contained in the class?
      11. 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?
      12. Are there any private methods? What do these method/s do? Are the comments sufficient?
      13. It seems like each color is defined twice (such as RED and red). What version of Java implemented the uppercase name of the color?
    5. Thought questions about the code:
      1. Why do you think there are two “versions” (that are the same, except for the name) of each color? What happened?
      2. After the uppercase version of the Color was created, why didn’t the authors just delete the lowercase version?
      3. 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?
      4. Define backward compatibility. How does the Color class demonstrate the concept of backward compatibility?
  2. Oracle makes this source code available. However, it is licensed and owned by Oracle. Therefore, can you modify this code? Is this truly open source??

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

Coding standards were not originally followed when the Color class was created. The naming standard for static final variables is that they should be all uppercase, with words separated by _. To rectify this error and still allow the class to support backward compatibility for the thousands of lines of code in production already, the class now supports two names for each constant color.

ACM BoK
Area & Unit(s)

PL and SDF

ACM BoK
Topic(s)

PL/Object Oriented Programming and SDF/Fundamental Programming Concepts

Difficulty

Medium

Estimated Time
to Complete

45 minutes

Environment /
Materials

Access to Java 1.7 SE JDK download

Author(s)

E. Brannock

Source

None

License

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

CC license.png


Suggestions for the Open Source Project

None.

Personal tools
Namespaces
Variants
Actions
Events
Learning Resources
HFOSS Projects
Evaluation
Navigation
Toolbox