Sunday, August 30, 2009

FizzBuzz

On the first day of ICS 413, Dr. Johnson instructed us to implement the FizzBuzz program in Java. My first thought upon hearing the assignment was "I've forgotten a lot of Java knowledge!" Over the summer I had been doing programming in Maple, a technical computing software, during a mathematics research program; moreover, the last time I did any programming in Java was almost a year ago, last fall. So although I could immediately visualize the algorithm that I wanted to implement, it took a little bit of thinking to remember Java's syntax.

In the time given in class to write the program by hand (around five minutes, I think), I was able to complete the program with what I believe would have amounted to a few syntactical errors. Later, when I used the Eclipse IDE to write the program, I had no problems and was able to implement the program within a few minutes.



Program description:
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".



My program:

/*
*  This program prints out the number from 1 to 100, inclusive, with one
*  number on each line. However, if the number is divisible by three, it
*  instead prints the word "Fizz", if the number is divisible by five, it
*  instead prints the word "Buzz", and if the number is divisible by both
*  three and five, it prints the word "FizzBuzz".
*/
public class FizzBuzz {
  
public static void main(String[] args){
      
      
// Loop through the number from 1 to 100
      
for(int i=1; i<=100;i++){
          
if(i%15==0){
              
/*
                *  If the number is divisible by both 3 and 5 (i.e.
                *  divisible by 15), print out "FizzBuzz".
                */
              
System.out.println("FizzBuzz");
          
}
          
else if(i%3==0){
              
// If the number is divisible by 3, print out "Fizz".
              
System.out.println("Fizz");
          
}
          
else if(i%5==0){
              
// If the number is divisible by 5, print out "Buzz".
              
System.out.println("Buzz");
          
}
          
else{
              
/*
                *  If the number is not divisible by 3 or 5 (or both),
                *  then print out the number.
                */
              
System.out.println(i);
          
}
       }
   }
}




This experience has shown me that even the simplest of programs can be good exercises to get used to programming in a language that one has learned in the past but may have not used recently. Also, the experience has shown me not to dismiss programming assignments as trivial or to underestimate an assignment.

Evaluation of PDF Split & Merge

Recently, I downloaded, installed, and made some trial runs of PDF Split and Merge (PDFsam). The program provides a way to split the pages of PDF documents into smaller files, and a way to merge selected pages from multiple PDFs.

I downloaded PDF Split and Merge Basic Version 2.0.0 for Windows from SourceForge.net. On the website, the program describes itself as "an easy to use tool to merge and split pdf documents". I first tested version 1.2.0, which was available when I initially downloaded the program on Wednesday, August 26, but after writing part of this review I checked the website again and was pleasantly surprised to find a newer version. This evaluation will focus on the most recent version, although I will make some comments on changes within the program.

To evaluate the program, I will be using Philip Johnson's Three Prime Directives for Open Source Software Engineering. In summary, the three prime directives are:
  1. The system successfully accomplishes a useful task.
  2. An external user can successfully install and use the system.
  3. An external developer can successfully understand and enhance the system.
First of all, this program definitely accomplishes a useful task. I found PDFsam while browsing SourceForge.net, and the program caught my eye because it sounded like something I would find extremely useful. In the past, I have had to both send and receive long PDF documents where only a few pages were necessary. Recently, I received a 130 page document of which only one page was truly relevant, and I needed only one other page for minor references. In instances like this, I would have appreciated a program that would allow me to pick out selected pages from the document, which would make browsing for information much easier.

Second, it is relatively easy to successfully install and use the program. PDFsam used an installation wizard and fully explained each step and installed exactly as expected. Upon opening the program initially (in version 1.2), I found the layout very sparse and somewhat void of directions. However, a tutorial file is included in the installed files, and after reading the tutorial, I found it easy to use the program. My one other problem arose when I couldn't figure out how to run the program on selected files, because the "Run" button is located at the bottom of the window and I needed to scroll down to see it.

Finally, I believe that as an external developer, I would find this program to be very difficult to enhance. After looking through the documentation provided during installation, on SourceForge.net and at PDFsam.com, I was unable to find any resources for developers. Without this documentation, I feel that it would be next to impossible to interpret code if it was necessary to adapt the program for my own purposes.

Overall, PDFsam is an extremely useful program and is easy to use after a slight learning curve. I will definitely keep this program installed on my computer and continue to use it.


Links referenced this post: