Better: Try to get it done by noon, Thursday 06/28
so that you can ask questions in class
on Thursday if you run into problems,
and get a start on H04!
Note that H04 is due
Thursday 07/05 at 11:55pm!
So you need to get done with this one!
In this homework assignment, we'll take several steps towards a more professional approach to software development than you may be used to from previous CIS courses.
If you are doing open source development, you have to distribute your source code. This is usually done in the form of a tarball (gzipped tar file), or a zip file.
In this homework, we'll see how we can automate this process using Ant.
Distributing your source means other folks need to be able to use it. That means you need to document well. In this homework assignment, we'll learn how to use Ant and Javadoc to help automate this process.
However, this process cannot be fully automated. It requires discipline, thought, creativity, and some effort on your part. It is a process that is both a skill and an art. (More on this below)
Other people will be using your code. So you would really hope you find all the bugs before you distribute it.
We'll get more practice with using Ant and JUnit to do test-driven development in this homework assignment.
You may want to use software by folks you've never met, and they may want to use your software. But, in a given Java program, you can't have two classes with the same name. How can you be sure you won't have any names that conflict?
In this homework assignment, we'll learn how to use the package feature of Java to address this problem.
We won't take these two items on in this particular assignment, but soon we'll be learning SubVersion: a source code revision control system that will help us with those two particular aspects of professional open source development.
The ability to write good documentation is not something I can directly pour into your brain like a "fact" (e.g. "Dover is the capital of Delaware", "Sacramento is the capital of California" ) —rather, it is a process—an art and a science that you have to teach yourself. I can only serve as a guide, and a coach.
However, if you talk to real-world professional programmers, they'll tell you that this is a very important real world skill! So if we want you to be a highly qualified software professional when you graduate, we need to take this on together.
The code distributed with this homework assignment is my attempt to point you in the right direction. But to learn to write you will have to study it, and ask yourself—and me, and each other—what makes the documentation good or bad.
You'll probably have to write lots of bad documentation, and listen to me explain how to make it better, before you can start writing good documentation. We'll need to have lots of conversations about what distinguishes good from bad documentation—recognizing that it is difficulty to come up with "absolute rules" about something that is rather subjective.
Suppose you find two classes out there that you want to use in your program:
One class is called PhotoBuffer and it is used for reading pictures from a digital camera.
Yes, and furthermore, you need to use both of them in your code. How did they end up with the same name? Easy: they were developed by two different programmers who never imagined that they'd be used in the same program.
Fortunately, there is an easy solution to this problem in Java—it is called "packages". Every time you develop a Java class, you can put it into a package that has a unique name in all of the world, and you can be sure that there will never be a naming conflict.
We choose a package name this way:
edu.udel
edu.udel.cisc370
edu.udel.cisc370.jstudent
edu.udel.cisc370.jstudent.Formats
Actually, we could leave out the cisc370
part, but it is good to include it, to distinguish Java packages you develop for this course from those you might develop for another course.
At the top of each of your source files, the very first line of code (other than comments) should be:
package edu.udel.cisc370.jstudent.Formats;
You also must create a subdirectory tree that mirrors this package name, and put your code in that subdirectory tree, like this:
> mkdir -p edu/udel/cisc370/jstudent/Formats > cd edu/udel/cisc370/jstudent/Formats > emacs MyClass.java
Compiling then gets a little trickier. If you stick with compiling with Ant (following the example in this homework assignment) it should all just "work out", but if you try compiling at the command line, you'll need to learn a bit more.
All the details about using packages, and compiling at the command line with packages are explained very nicely in your textbook! I strongly encourage you to look over this before starting the assignment.
In your HFJ textbook on these pages: | p154-155, p587-589, p590, p591 |
Also see the reading notes on the wiki for these pages: |
p154-155, p587-589, p590, p591 |
If you have a Safari subscription, these links will take you to the pages |
p154-155, p587-589, p590, p591 |
Please review the rules from H02 regarding collaboration.
In this assignment, you'll work with a package called Formats, containing two classes.
FormattedTitles is used to produce titles that are formatted nicely. For example, you might want to center the words "Welcome to my program" in a field of 80 characters, like this:
Welcome to my program 12345678901234567890123456789012345678901234567890123456789012345678901234567890
Here, we have 29 spaces before the words, and 30 afterwards, approximately centering the words in the 80 character wide space. The FormattedTitles class can do this with the following code:
System.out.println(FormattedTitles.CenteredTitle("Welcome to my program",80));
The class has three other methods to do various kinds of formatted titles. You can browse the JavaDoc for this class here: http://www.udel.edu/CIS/370/pconrad/07J/hwk/H03/Formats/javadoc/
In fact, you can find a complete distribution of this package, at the following link:
: http://www.udel.edu/CIS/370/pconrad/07J/hwk/H03/Formats
But, before you can do that, you need to set up your development environment for this project.
Here's what you need to do:
chmod -R a+rx ~/public_html/cisc370
If you do, you should then find that the web link below (after you change youruserid to, well, your user id)
then has a distribution of this code, just like the one under the link
The next thing you should do is change the name of the package from edu.udel.cisc370.pconrad.Formats,
substituting your own userid in place of pconrad
. This will require
What exactly these changes are is something I'm leaving as an exercise to you. Figuring this out will require you to do the reading about packages in your HFJ textbook, and the reading about Ant and JUnit in your XP Cookbook.
(The todo list appears above. There is also list of hints in a comment in both the FormattedTitles.java
and FormattedTitlesTest.java
source files.)
Then when you are finished with that to-do list, see if there is anything else that needs to be done for this package to be usable. When you are satisfied that it is complete, submit it, following the instructions below.
Submit your work on WebCT for the assignment marked H03. Upload and submit BOTH
H03.txt
file, which is a script of your programs. H03.tgz
or H03.zip
file, containing all of your java source code, and where applicable, sample input files. (It doesn't matter whether you submit a tgz
or zip
file—only one of the two is required.) Your tar or zip files should NOT contain your .class files—but if you followed the build.xml example properly, your "ant dist" task should create a tarball and zip file automatically that is in the proper form.
In addition—go to the Wiki page named 07J_H03, and make sure that there is a link to your distribution on that page.
Re-read the notes from H02 about scripting before you do your script.
Hint: A good practice would be to incorporate your scripting strategy into an Ant target, so that when you go to script, the process is automated!
A reminder: even though your distribution file contains your Java source, you are still required to "cat" this source code in your .txt file, and submit it in both forms. If you do not, you will lose points.
Here's why: Submitting both allows your TA the ability to
Of course, the two should agree—if they don't, that's also a potential grading deduction. So if you make changes to your code, be sure that you redo both your script, and your tar/zip file.
Item | Description | Points |
---|---|---|
Functionality | The program actual works—it does what it is supposed to do when you run it | 25 |
Unit Testing | Your code includes appropriate Unit tests, and those unit tests can be run from the build.xml file. | 20 |
Style | The program logic is clear and well documented. It is easy for someone to read your program and understand how the program works. | 15 |
Deployment | The build.xml file is clear, and operates correctly. It contains tasks for compiling, running unit tests, running the code, producing javadoc (and deploying it to the web), and creating a distribution file and posting it to the web. | 10 |
Web Site | There is a web site under your userid on copland.udel.edu where your javadoc is available, your code is available (in tarball/zip and browsable source form). There is a brief explanation of your code, and link to the assignment. You have updated the indicated wiki page with a link to this site. | 10 |
Scripting | Your script clearly demonstrates the functions of the program, and includes a reasonable amount of testing. | 10 |
Following Directions | Both submitted files (e.g. script and (tarball or zip)) are submitted according to directions, and all other aspects of the project comply with instructions given. | 10 |
Total Points |