Notes From Class
Week 1: August 31, September 2 and 4, 2009
-
I will soon be putting your picture on the
meet the class page.
If you have any objections (e.g., the mug shot isn't up to
your usual GQ/Vogue standards), please let me know.
-
The National Education Association has created a little 6 minute video called
Shift Happens.
Week 2: September 7, 9 and 11, 2009
Week 3: September 14, 16 and 18, 2009
-
If you couldn't come to class this week, we covered networks. What are they?
How did the Internet get started? Who uses the Internet?
How fast is it growing?
What services are provided by the Internet?
Please get a copy of the class notes from a friend.
-
The campus dialup services are now deceased (June 30, 2007).
If you want remote access your account at school,
then you'll need a high-speed internet connection.
-
You can test the speed of your internet connection with
http://www.dslreports.com/stest .
-
OIT has created a new service
SSH Gateway on the Web .
Note. Students from past semesters tell me that it works,
but it can be very slow!
-
If your machine is running MS Windows then
you are probably better off downloading putty.
-
If you machine is an Apple running Mac OS X,
then you can simply use the Terminal program.
Look under /Applications/Utilities.
-
Here is a link to the
Putty telnet and ssh client program.
Note. It seems that Putty cannot traverse firewalls.
So you make need to add "Putty" as an exemption to your list of
programs that can bypass the firewall on your computer. On Windows XP,
see the security folder inside the control panel.
-
On my PC at home I use TurboFTP to transfer files/directories to/from school.
TurboFTP has a very friendly graphical user interface
that shows both the windows and unix files systems.
You can download a trial version
from http://www.tucows.com .
You will need to adjust the program settings so that the
connection to school is secure -- use sftp and socket 22 (not socket 21).
-
If you have downloaded an FTP program to your PC/laptop at home,
then you'll need the IP addresses for computers on the glue system, i.e.,
Site IP addresses
--------------------------------------------------
glue.umd.edu 128.8.10.68
128.8.10.71
--------------------------------------------------
Insert them into the (ftp program) site manager.
-
If you have a Mac, simply use the "ssh" program from the terminal window (see /Applications/Utilities) to
remote login to school. For example:
prompt >> ssh glue.umd.edu
Once logged in you can transfer files back and forth with the "scp" command.
To transfer a file from your laptop to glue:
prompt >> scp file-name glue.umd.edu:
The file will be put in your home directory.
To copy a whole directory/folder of content:
prompt >> scp -r folder-name glue.umd.edu:
Again, the folder will be put in your home directory.
To download a file from glue to your laptop, type:
prompt >> scp glue.umd.edu:file-name .
The dot (.) at the end of the command means ... put the file in my present
working directory (command pwd).
Week 4: September 21, 23, and 25.
-
Prelude to Homework 1 ....
Make sure that you know how to log in to your glue account.
Read the instructions for creating a personal home page (pg. 23 of the green
class reader). Then start to read the "A Beginners Guide to HTML" tutorial.
Use a text editor (vi or pico) to type in the minimal html document
on pages 27-28 of the class reader.
Then go to the "meet the class page" and make sure that the link from your
entry to your home page works.
-
Here are a few basic UNIX commands:
Unix Commands
--------------------------------------------------------------------------------
1. cd <-- change to home directory
2. cd file1 <-- change to directory file1
3. ls and ls -ls and ls -tl <-- list contents of a directory
4. mkdir file1 <-- make a directory called file1
5. rmdir file1 <-- remove directory file1
6. cp file1 file2 <-- copy file1 to file2
7. mv file1 file2 <-- move file1 to file2
--------------------------------------------------------------------------------
Note. Directories cannot be removed unless they are empty.
Let's suppose that you have created a file and now you want to remove it. Try:
8. rm file1 <-- remove/delete file1
Text editor commands
--------------------------------------------------------------------------------
1. vi filename <-- use vi editor to change contents of filename.
For example, the command sequence:
prompt >> cd ../pub
prompt >> vi Welcome.html
prompt >> vi resume.html
prompt >> vi ce-systems.html
moves your shell to the public directory and then systemantically creates the
HTML files for your home page, resume page, and a write-up on ce-systems.
Notice that each file name has the "html" extension -- web browsers need this information.
The class reader contains a list of basic editor commands.
--------------------------------------------------------------------------------
-
A more extensive description of the UNIX directory structure,
file handling, and operating system commands can be found in
Appendix 1 of Austin/Chancogne (pg's 621-628).
-
Click here
to see a video of a multi-touch sphere/globe.
-
And here is
another link
to a video of the Microsoft Surface Table.
-
Homework 1 is available.
Due date is 9am, October 2, 2009.
-
If you couldn't come to class this week, we covered
the details of connecting to school using ssh (Mac) or putty (PC),
basic unix/mac os x file systems and commands, and the vi text editor.
You will need the latter to build your web page for homework 1.
Please get a copy of the class notes from a friend.
Week 5: September 28 and 30. October 2.
-
Let's suppose that you have copied your image files from home into the
home directory of your glue account.
Now you need to move the images to the /pub/images directory.
You can do this by moving to the image directory, i.e.,
cd ../pub
cd images
and then giving the command:
mv ~your-login-name/image-file .
The dot (.) means move the named file to the present working directory (/pub/images).
-
Copying a file from a Mac to the home directory of your glue account is easy.
Just go to the folder/directory where the image file is located on your Mac,
and from the Terminal window type:
scp image-file-name your-login-name@glue.umd.edu:
You will be prompted for your glue account password, and that's it.
If the account name on your Mac just happens to be the same as the login name
on your glue account (e.g., I use austin in both cases), then the "scp"
commands simplify to those shown above (see Week 3).
-
Cut-and-paste from a web browser to a putty window:
Here's what I found on a web tutorial:
If you are pasting INTO a putty session, you should just be able to
paste into the putty session with the middle (or both) mouse button(s).
So, for instance, you can find a command somewhere on my web site
using a browser, highlight it and hit CTRL-C then paste that
command directly into the putty window at the shell prompt by
hitting the middle mouse button.
-
Click here an example of RDF.
Week 6: October 5, 7 and 9.
-
Homework 2 is available.
Due date is 9 am, October 14, 2009.
-
Please read the article from Scientific American entitled: XML and the Second Generation
written by Jon Bosak and Tim Bray.
You can find it in the middle of the "green" book of lecture notes.
-
Click here to see a short video on smart lego blocks that turn touch screens into 3D
Week 7: October 12, 14 and 16.
-
Can't get xfig to work on your MacBook?
Click here
to try jfig (i.e., a java version of xfig).
-
Question: Do I have java on my Mac?
Yes. The Mac comes with Java 1.5 installed. To see where the java virtual machine
and compilers are located, type:
whereis javac
whereis java
-
Question: Do I have java on my PC?
Maybe yes and maybe no. If java is on your PC, then it will probably be
located inside the "Program Files" folder. If you have a folder called Java,
then that's a start. Look inside the Java folder to see if you have a folder
that looks like "JDK" for the java development kit. If the latter is true,
then you are good to go.
If you don't have java, then you can download it from:
http://java.sun.com/
Click on "downloads" and then go to the section entitled "JDK 6 Update 16"
and click on the "Download" button.
Please let me know if that doesn't work!!
Week 8: October 19, 21 and 23.
Week 9: October 26, 28 and 30.
-
Click here for a
Tutorial on Eclipse .
-
Internet Set for Change with Non-English Addresses
From Yahoo News
From Seoul, South Korea. The Internet is set to undergo one of the biggest changes in its
four-decade history with the expected approval this week of international domain
names -- or addresses -- that can be written in languages other than English,
an official said Monday.
The Internet Corporation for Assigned Names and Numbers, or ICANN -- the non-profit group
that oversees domain names -- is holding a meeting this week in Seoul.
Domain names are the monikers behind every Web site,
e-mail address and Twitter post, such as ".com" and other suffixes.
One of the key issues to be taken up by ICANN's board at this week's
gathering is whether to allow for the first time entire Internet addresses
to be in scripts that are not based on Latin letters.
That could potentially open up the Web to more people around the world as
addresses could be in characters as diverse as Arabic, Korean,
Japanese, Greek, Hindi and Cyrillic -- in which Russian is written.
This is the biggest change technically to the Internet since it was
invented 40 years ago," Peter Dengate Thrush, chairman of the ICANN board,
told reporters, calling it a "fantastically complicated technical feature."
He said he expects the board to grant approval on Friday, the conference's final day.
Week 11: November 9, 11, and 13.
-
Homework 4 is available.
Note: I changed the question numbers from those given in class
Due date is 9am, November 20, 2009.
Week 12: November 16, 18, and 20.
Week 13: November 23, 25, and 27.
-
Midterm 2 (35%): November 23. Open book and open notes.
This exam will cover the basics of programming in Java (e.e., data and variables,
formatted output, branching constructs, looping constructs, one- and two-dimensional arrays).
-
Nov. 25 -- Class cancelled. Please spend the day travelling to your family.
-
Nov. 27 -- Thanksgiving holiday.
Week 14: November 30. December 2 and 4.
-
Homework 5 is available ( pdf ).
I will provide hardcopies in class on Wednesday.
Due date is December 11, 9 am, No extensions!
Week 15: December 7, 9 and 11.
-
Hint for Problem 4: You will need to add concrete implementations
of the methods getX() and getY() to all classes that extend Shape.java.
Here is a sample of what I have -- in Circle.java, Rectangle.java and
Triangle.java, simply write:
public double getX() {
return c.dX;
}
The (abbreviated) output that I get for Problem 4 is as follows:
prompt >> java EngineeringProperties
.... details of output omitted ....
Total Area = 5.86
---------------------------------
Moments of Inertia (about coordinate axes)
I_xx = 51.840
I_yy = 91.070
I_xy = 64.550
Centroid(X) = 3.84
Centroid(Y) = 2.84
Moments of Inertia (about centroid)
I_xx = 4.380
I_yy = 4.380
I_xy = 0.408
Orientation of Principal Axes
Angle = 0.785 radians
Angle = 45.000 degrees
prompt >>
-
Java Collections
Now that we know how to create objects,
the next thing to think about is their organization.
How, for example, do you organize (or aggregate) large numbers of
objects so that things are easy to find and modify?
A
collection
is an object that groups multiple elements into a single unit.
Collections are used to store, retrieve, manipulate, and communicate aggregate data.
Typically, they represent data items that form a natural group:
-
A poker hand (a collection of cards),
-
A mail folder (a collection of letters), or a
-
Telephone directory (a mapping of names to phone numbers).
A collections framework is a unified architecture for representing and
manipulating collections. This framework provides the following benefits:
-
Reduces programming effort
-
Increases programming speed and quality
-
Provides a standard way of accessing collections
-
Allows for effective reuse of code.
All collections frameworks contain the following:
-
Interfaces:
These are abstract data types that represent collections.
Interfaces allow collections to be manipulated independently of the details
of their representation.
-
Implementations:
These are the concrete implementations of the collection interfaces.
In essence, they are reusable data structures.
-
Algorithms:
These are the methods that perform useful computations,
such as searching and sorting, on objects that implement collection interfaces.
In the Java Collecctions Framework the interfaces are organized as follows:
Figure 1. Hierarchy of interfaces in the Java Collections Framework.
Units include:
-
Sets.
A set is a collection that cannot contain duplicate elements.
-
Lists.
An ordered collection (sometimes called a sequence).
Lists can contain duplicate elements.
The user of a List generally has precise control over
where in the list each element is inserted and can
access elements by their integer index (position).
-
Queues.
Queues typically order elements in a FIFO (first-in-first-out) manner.
-
Maps.
An object that maps keys to values.
A Map cannot contain duplicate keys.
Each key can map to at most one value.
-
SortedSet
A Set that maintains its elements in ascending order.
Several additional operations are provided to take
advantage of the ordering.
Sorted sets are used for naturally ordered sets,
such as word lists and membership rolls.
-
SortedMap
A Map that maintains its mappings in ascending key order.
This is the Map analog of SortedSet.
Sorted maps are used for naturally ordered collections of key/value pairs,
such as dictionaries and telephone directories.
Collections are used to store, retrieve, manipulate, and communicate aggregate data.
Typically, they represent data items that form a natural group.
General Purpose Implementations
A simplified view of the relationship between containers and
the Set, List and Map interfaces is as follows:
Interfaces |
Hash Table |
Resizeable Array |
Balanced Tree |
Linked List |
Set |
HashSet |
|
TreeSet |
|
List |
|
ArrayList |
|
LinkedList |
Map |
HashMap |
|
TreeMap |
|
In practice, an implementation will follow:
Figure 2. Taxonomy of interfaces, abstract classes, and concrete classes
in the Java Collections Framework.
Points to note:
-
There are only three container components -- Map, List and Set,
and as shown above only 2 or 3 implementations of each one.
-
The dotted boxes represent interfaces, the dashed boxes represent abstract classes,
and the solid boxes are regular (concrete) classes.
-
The dotted-line arrows indicate that a particular class is implementing an
interface (or in the case of an abstract class, partially implementing that interface).
The solid arrows show that a class can produce objects of the class the arrow is pointing to.
For example, any Collection can produce an Iterator and a List can produce a
ListIterator (as well as an ordinary Iterator, since List is inherited from Collection).
Bottom Line/Review
Containers provided in the standard Java library (Adapted from Eckel, Edition 3):
-
An array associates numerical indices to objects.
It holds objects of a known type so that you don't have to
cast the result when you are looking up an object.
It can be multidimensional, and it can hold primitives.
However, its size cannot be changed once you create it.
-
A Collection holds single elements, and a Map holds associated pairs.
-
Like an array, a List also associates numerical indices to
objects. You can think of arrays and Lists as ordered containers.
The List automatically resizes itself as you add more elements.
But a List can hold only Object references,
so it won't hold primitives, and you must always cast the
result when you pull an Object reference out of a container.
-
Use an ArrayList if you are doing a lot of random accesses,
but a LinkedList if you will be doing a lot of
insertions and removals in the middle of the list.
-
The behavior of queues, deques, and stacks is provided via the LinkedList.
-
A Map is a way to associate not numbers,
but objects with other objects.
The design of a HashMap is focused on rapid access,
whereas a TreeMap keeps its keys in sorted order,
and thus is not as fast as a HashMap.
A LinkedHashMap keeps its elements in insertion order.
-
A Set only accepts one of each type of object.
HashSets provide maximally fast lookups,
whereas TreeSets keep the elements in sorted order.
LinkedHashSets keep elements in insertion order.
-
There is no need to use the legacy classes Vector, Hashtable, and Stack in new code. Feedback
-
Hint for Problem 5:
In this problem we will use an arraylist to store the collection of shape objects.
The script of code:
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class EngineeringProperties2 {
public static void main ( String args[] ) {
// Create and initialize a grid of ten shapes
List shapes = new ArrayList();
Shape s0 = new Rectangle( 0.25, 0.25, 0.0, 2.0 );
shapes.add ( s0 );
.... etc ....
imports the appropriate packages and initializes an arraylist with the
first item. To compute the engineering properties we walk along
the array, retrieve the items and make the appropriate calculation, e.g.,
double dArea = 0.0;
for (int ii = 1; ii <= shapes.size(); ii = ii + 1) {
Shape s = (Shape) shapes.get(ii-1);
dArea = dArea + s.area();
}
-
December 11. Hand in homework 5 and pick up solutions.
Review of material for the final exam.
Week 17: .....
Developed in August 2009 by Mark Austin
Copyright © 2009, Department of Civil and Environmental Engineering,
University of Maryland