Difference between pages "FOSS Field Trip Activity V1" and "Finding the Code Responsible for Behavior"

From TeachingOpenSource
(Difference between pages)
 
m (29 revisions imported)
 
Line 1: Line 1:
== FOSS Field Trip Activity ==
__NOTOC__


=== Title: Browsing A Forge ===
{{Learning Activity Overview
|title=
Finding the Code Responsible for Behavior
|overview=  
Java learners often wonder why certain behaviors are exhibited when a method is invoked.
They tend to view the entire mechanism as "magic".
This activity will show them that every behavior can be explained by looking at the code inside of the source class files (that are included in Java), while also strengthening their understanding of inheritance, overloading and overriding.
|prerequisites=
Invocation of Java methods (especially System.out.println and overloading), some inheritance concepts, some familiarity with the toString() method and overriding.
|objectives=
# Fully understand the interaction of the println method with the toString method
# Inheritance
# How to locate the code responsible for the behavior of a method
# what an overload is (println) 5) what an override is (toString)
|process skills=
}}


=== Description ===
=== Background ===
Learners will gain an understanding of the breadth of available FOSS projects. Learners will also gain an understanding of the identifying characteristics of FOSS projects including pattern of contributions, patterns of commits, programming languages used, and more.
 
Students should be able to create an ArrayList and print it to the console (without a for loop). Students should also be able to read the Java API and understand inheritance at a high level.
 
=== Directions ===
 
I can easily create an ArrayList of String named al, and add "a", "b", "c" and "d" to it. Then I can quickly print it out using the line of code System.out.println(al); This produces the output [a, b, c, d].
Have you ever wondered why the output looks like this? Why are those "weird" brackets included in the output? Why are there commas between each String? Let's discover the answer!
 
== Part 1 - Read the API ==


=== Source ===
# Find the println method in the API. There are many println methods. Which overloaded println is used when you println an ArrayList? What method does the println call according the to API?
[http://www.xcitegroup.org/softhum/doku.php?id=f:assignment_ossfieldtrip1detail Detailed FOSS Field Trip]
# Since println invokes String.valueOf, navigate to this method. What method does String.valueOf invoke?
# Now you can see that String.valueOf invokes the toString method of the object. What class does al belong to? Isn't it ArrayList?
# Let's navigate to the ArrayList class. What class does ArrayList inherit its toString method from? This is the toString method we want to dissect.


=== Prerequisite Knowledge ===
== Part 2 - Look at the Source Code in OpenJDK for Java  ==
None.


=== Estimated Time to Completion ===
# OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java programming language.
30-60 minutes
# If you do not already have it downloaded, discover how you can download the source code for Java from OpenJDK.
# Understand the sub-directory structure. How does this relate to package/import statements?
# Open the java source code for the class that you determined contains the toString that is executed to produce the output [a, b, c, d].


=== Learning Objectives ===
== Part 3 - Find the code ==
Ability to:
* Locate a FOSS project on SourceForge and Ohlog.
* Describe basic features of the project including start date, programming language, code size, and recent activity.
* Compare two similar FOSS projects based on same criteria.


=== Materials/Environment ===
# Find the toString in the Java source code that is executed to produce the output [a, b, c, d].
* Access to Internet/Web and web browser.
# Read and understand this method.
# Copy and paste the code in the method, and explain the method in English.
## Indicate the line of code that produces the  "[".
## Indicate the line of code that produces the  "]". 
## Indicate the line of code the places the comma and space between the elements in the ArrayList.


=== Background ===
== Part 4 - Open source vs. licensed code ==
Open source pre-dates the Web, but the Web and Internet connectivity have been essential for the blossoming of FOSS in recent years. FOSS projects need to be available on the Web to ever gain much attention. There is a growing number of sites (often called “forges”) that provide a home and visibility to FOSS projects (although many of the biggest projects live on their own sites).  


=== Directions ===
# Oracle makes this source code available. However, it is licensed and owned by Oracle. Therefore, can you modify this code? Is this open source??
==== Part 1 - SourceForge ====
# What would be the proper way to change the way an ArrayList is output to a console.  
Perhaps best known of these FOSS sites is Source Forge. In this activity you will explore projects in SourceForge to gain an understanding of the key characteristics of a FOSS project.  


Do the following:
# Go to: http://sourceforge.net/
# Use the Search feature in the center of the screen to view applications in an area of interest to you (e.g., gaming, sports, music, computing, etc.).
# How many projects are there in this category?
# How many different kinds of applications are there?
# How many different programming languages are used to write software in this category?
# List the top four programming languages used to write programs in this category.
# How many of the projects in this category are written in the programming language of your choice?
# Identify the meaning of each of the statuses below:
## Inactive
## Mature
## Production/Stable
## Beta
## Alpha
## Pre-Alpha
## Planning
# Compare two projects in this category that have two different statuses. Describe the differences between the statuses.
# Which projects are the most used? How do you know?
# Pick a project in your category. Answer the questions below:
## What does it do?
## What programming language is the project written in?
## Who is likely to use the project? How do you know this?
## When was the most recent change made to the project?
## How active is the project? How can you tell?
## How many committers does the project have?
## Would you use the project? Why or why not?
# Look for projects that have a humanitarian purpose. That is, projects for which the primary purpose is to provide some social benefit such as economic development, disaster relief, health care, ecology. Examples include Mifos, Sahana and OpenMRS.
# Find several additional examples of humanitarian FOSS projects.
# Pick one humanitarian FOSS and look at the data available about it.
# How would you decide whether it was worth using?
# How would you decide whether it was worth contributing to as an IT professional?


==== Part 2 - Ohloh ====
=== Deliverables ===
Comparison of Epiphany, Firefox and K-Meleon using Ohloh.net
In this activity, you’ll explore some of the development characteristics of web browsers, one of which was presented today including the number of developers and the programming languages used in each.


'''Explore Epiphany:'''
A document with answers to questions
# Go to: http://www.ohloh.net/
# In the upper-most search space, enter:  Epiphany
# Click on the Epiphany logo.
# What is the main programming language used in Epiphany?
# How many lines of code does Epiphany have?
# Click on the World Activity Map (lower right side of screen). List some of the locations of the developers:
# Go back to the main Epiphany page and click on the “Code Analysis” link under right-hand DEVELOPMENT menu.
# What other languages is Epiphany written in?
# What language has the second highest number of lines of code?
# Of the programming languages used in Epiphany, which language is the most highly commented?
# Click on the “Contributors” link under right-hand COMMUNITY menu.
# How long have the top three contributors been involved in the project?
# Click on the “Managers” link under right-hand COMMUNITY menu.
# How many managers does the project have?


'''Explore Firefox:'''
=== Assessment ===


# Go back to the Ohloh main page: http://www.ohloh.net/
TBD
# In the upper-most search space, enter:  Firefox
# Click on the Firefox logo.
# What is the main programming language used in Firefox?
# How many lines of code does Firefox have?
# Click on the World Activity Map (lower right side of screen). List some of the locations of the developers:
# Go back to the main Firefox page and click on the “Code Analysis” link under right-hand DEVELOPMENT menu.
# What other languages is Firefox written in?
# What language has the second highest number of lines of code?
# Of the programming languages used in Firefox, which language is the most highly commented?
# Click on the “Contributors” link under right-hand COMMUNITY menu.
# How long have the top three contributors been involved in the project?
# Click on the “Managers” link under right-hand COMMUNITY menu.
# How many managers does the project have?


'''Comparison of Epiphany, Firefox and K-Meleon'''
=== Comments ===


# Go back to the Ohloh main page: http://www.ohloh.net/
I used an in-class activity based on this description for two semesters now.
# Click on the “Compare Project Metrics” link on the lower left side of the page.
Here is the link to the specific activity description and worksheet: https://goo.gl/6R6c2B.  
# Enter Epiphany in the first column and select Epiphany browser.
The students work in small groups during the recitation.
# Once the information of Epiphany is displayed, enter Firefox in the second column.  
# Repeat using K-Meleon in the third column.
# Which project has more developers?
# Which project is older?
# Which project has the largest number of developers in the past 12 months?
# Which project has the larger number of lines of code?


=== Additional Information ===
=== Additional Information ===
List of other supporting material. Likely to be links to web sites.


=== Rights ===
{{Learning Activity Info
Licensed CC BY-SA
|acm unit=
PL
|acm topic=
PL/Object Oriented Programming
|difficulty=
easy
|time=
20 minutes
|environment=
Access to Java OpenJDK 7 or 8  and access to Java 7 or 8 API
|author=
E. Brannock
|source=
N/A
|license=
{{License CC BY SA}}
}}
 
=== Suggestions for the Open Source Project ===
 
N/A


[[Category: Foss2serve]]
[[Category:Learning Activity]]
[[Category: Learning_Activity]]
[[Category:Coding and Style]]
[[Category:CS2]]
[[Category:Good Draft]]

Revision as of 16:52, 13 November 2021


Title

Finding the Code Responsible for Behavior

Overview

Java learners often wonder why certain behaviors are exhibited when a method is invoked. They tend to view the entire mechanism as "magic". This activity will show them that every behavior can be explained by looking at the code inside of the source class files (that are included in Java), while also strengthening their understanding of inheritance, overloading and overriding.

Prerequisites

Invocation of Java methods (especially System.out.println and overloading), some inheritance concepts, some familiarity with the toString() method and overriding.

Learning
Objectives
After successfully completing this activity, the learner should be able to:
  1. Fully understand the interaction of the println method with the toString method
  2. Inheritance
  3. How to locate the code responsible for the behavior of a method
  4. what an overload is (println) 5) what an override is (toString)
Process Skills
Practiced


Background

Students should be able to create an ArrayList and print it to the console (without a for loop). Students should also be able to read the Java API and understand inheritance at a high level.

Directions

I can easily create an ArrayList of String named al, and add "a", "b", "c" and "d" to it. Then I can quickly print it out using the line of code System.out.println(al); This produces the output [a, b, c, d]. Have you ever wondered why the output looks like this? Why are those "weird" brackets included in the output? Why are there commas between each String? Let's discover the answer!

Part 1 - Read the API

  1. Find the println method in the API. There are many println methods. Which overloaded println is used when you println an ArrayList? What method does the println call according the to API?
  2. Since println invokes String.valueOf, navigate to this method. What method does String.valueOf invoke?
  3. Now you can see that String.valueOf invokes the toString method of the object. What class does al belong to? Isn't it ArrayList?
  4. Let's navigate to the ArrayList class. What class does ArrayList inherit its toString method from? This is the toString method we want to dissect.

Part 2 - Look at the Source Code in OpenJDK for Java

  1. OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java programming language.
  2. If you do not already have it downloaded, discover how you can download the source code for Java from OpenJDK.
  3. Understand the sub-directory structure. How does this relate to package/import statements?
  4. Open the java source code for the class that you determined contains the toString that is executed to produce the output [a, b, c, d].

Part 3 - Find the code

  1. Find the toString in the Java source code that is executed to produce the output [a, b, c, d].
  2. Read and understand this method.
  3. Copy and paste the code in the method, and explain the method in English.
    1. Indicate the line of code that produces the "[".
    2. Indicate the line of code that produces the "]".
    3. Indicate the line of code the places the comma and space between the elements in the ArrayList.

Part 4 - Open source vs. licensed code

  1. Oracle makes this source code available. However, it is licensed and owned by Oracle. Therefore, can you modify this code? Is this open source??
  2. What would be the proper way to change the way an ArrayList is output to a console.


Deliverables

A document with answers to questions

Assessment

TBD

Comments

I used an in-class activity based on this description for two semesters now. Here is the link to the specific activity description and worksheet: https://goo.gl/6R6c2B. The students work in small groups during the recitation.

Additional Information

ACM BoK
Area & Unit(s)

PL

ACM BoK
Topic(s)

PL/Object Oriented Programming

Difficulty

easy

Estimated Time
to Complete

20 minutes

Environment /
Materials

Access to Java OpenJDK 7 or 8 and access to Java 7 or 8 API

Author(s)

E. Brannock

Source

N/A

License

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

CC BY SA.png


Suggestions for the Open Source Project

N/A