Tuesday, August 30, 2011

FizzBuzz in Eclipse

FizzBuzz in Eclipse

The following article provides insight into the FizzBuzz problem presented to prospective computer programmers:

You Can't Teach Height - Measuring Programmer Competence via FizzBuzz

“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 that are multiples of both three and five print “FizzBuzz”.

In retrospect, I did not expect to encounter any problems when implementing the FizzBuzz application in Eclipse. Having some experience with Eclipse over the years and a copy of my in-class solution to this problem, I was confident the application would produce the correct output on the first run.

Expected output for the first 15 numbers:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz

Actual output from my implementation for the first 15 numbers:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
Fizz

Obviously this wasn’t correct.

Without really thinking too much about the logic of the program, my checking conditions produced erroneous output as a result of the order I checked the value of number. By checking for numbers divisible by both 3 and 5 after checking for the values of 3 and 5, the application would print “Fuzz” for the values of 15, 30, etc. instead of “FizzBuzz”. By simply checking for the remainder of number and 15 as the first condition fixed this problem.



It took me 05:05.5 to complete the application with correct output, and 12:04.0 to finish writing in my comments.

Sunday, August 28, 2011

Open Source Software and the Three Prime Directives

PDF Split and Merge http://www.sourceforge.net/projects/pdfsam/


Overview: PDF Split and Merge is a simple, easy to use, free, open source application to split and merge PDF documents. There are console and GUI versions of the application where the GUI is written in Java Swing. A variety of external libraries is utilized to deal with the manipulation of PDF files, XML format, and encrypted documents.

Prime Directive 1: The system successfully accomplishes a useful task.

A simple Google search on how to merge or split PDF documents will reveal a variety of free and paid solutions for the end-user. A browser-based solution, while free to some extent, is only limited to 15 MB files and offers no split functionality. A DIY method is available but only for Mac OS X users. With that said, PDF Split and Merge allowed me to quickly merge two existing PDF documents in less than a minute. Although the interface could be a little more intuitive, patient users will find the process painless by reading the manual that offers a how-to on merging and splitting PDF documents.


Prime Directive 2: An external user can successfully install and use the system.

The PDF Split and Merge website, http://www.pdfsam.org, has installers available for Windows and Max OS X, a ZIP archive, and the source code. The tutorial from the site describes that a Java Runtime Environment is required to run the application. A detailed explanation of each function in the system is available to help the end-user complete basic tasks such as Merge/Extract and Split.

Prime Directive 3: An external developer can successfully understand and enhance the system.

A Software Requirements Specification document is available at http://www.pdfsam.org/uploads/PDFsam-SRS-v2.1.0-EN.pdf. This developer-level documentation details the basic version of PDF Split and Merge that allows external developers to understand the system and to help improve it. A feature request tracker, https://sourceforge.net/tracker/?atid=814268&group_id=160044&func=browse, has a couple dozen suggestions to improve the system’s feature set. For example, this program is currently limited to merging exactly two documents at a time. Going through the API and source code shows a lack of descriptive comments; however the methods are named in such a way to help an external developer understand the program.

Three Prime Directives of Java-based Open Source Software Engineering: