Tuesday, August 30, 2011

FizzBuzz

FizzBuzz with Eclipse

After reading the blog posts by Jeff Atwood here and by Scott Hanselman here, I implemented the FizzBuzz program using Eclipse in about 7 minutes - including coding a
junit test class. Since I knew a solution ahead of time, the bulk of the time was spent typing, rather than devising an algorithm. Using junit for the first time, I used control+space in Eclipse to see the available methods in the org.junit.Assert class. When I forgot to use String.valueOf() when dealing with integer values (the method return type is String), Eclipse flagged this error in real-time as I was typing. I was able to correct it immediately rather than wait for a compile time error to realize my mistake had I been using an ordinary text editor and javac.

FizzBuzz.java





FizzBuzzTest.java



I implemented an alternate FizzBuzz algorithm by adding another method to my FizzBuzz class and tested it using junit as well. I used "refactor code" in Eclipse and all the method names in the junit test class were changed for me automatically. In addition I used "window->preferences" in Eclipse to change the style of the braces and add blank lines to the code automatically while typing as well as when using "source->format" from the context menu.

Summary

I learned some valuable lessons by reading the blog posts mentioned above and coding the FizzBuzz program with Eclipse. It's a good thing to be able to commit a working knowledge of correct Java syntax to memory, even though it's easy to look at or cut-n-paste existing code, use the API documentation, or search for code examples using Google. With so many Java classes in the API it's not possible, or even time well spent, to memorize every class! However, the basic syntax, such as what's needed to create the FizzBuzz program, is a requirement for any programmer taking his profession seriously. I also gained some insights into the mindset of interviewers, and feel that becoming an expert Eclipse user will be a very valuable skill, increasing my productivity and efficiency when coding.

Reflection on ICS 613

Based upon our assignments and readings to date, I feel ICS 163 will benefit us by introducing and/or reinforcing concepts and skills that are essential to being a successful software engineer.

Saturday, August 27, 2011

Open Source Software and the Three Prime Directives

Overview: 7-zip

7-Zip is the package I chose to download, which is a file archive pack/unpack utility supporting an everyday task for most software professionals and even end users. 
Its stated objectives include a high compression ratio and support for many/most file archive formats encountered on modern computer systems. Additionally it is claimed to run under most flavors of Windows as well as Linux/Unix.

7-zip can be downloaded at:        http://sourceforge.net/projects/sevenzip

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

Given the overview above, it is obvious that the functionality promised by 7-zip would be
both useful and beneficial. Therefore it qualifies as a utility that provides an extremely useful everyday task for a broad range of computer users, since a large number of downloaded files are packed, and conversely there is a need to pack files and/or directories before emailing or uploading them to other users.
 
What other useful functionality is provided? Aside from the basic tasks of packing/unpacking archives, 7-zip provides features such as encryption, self-extracting capability, integration with the Windows shell, a file manager, a command line version, and localizations for 79 languages.

So the system satisfies PD1: successfully accomplishing a useful task.


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

Achieving Success with 7-zip was easy. One
click to download, run the downloaded .exe file to install it, and simply choose the install directory was all that was required.

I was able to use 7-zip immediately with no instruction, readme file, release notes, or documentation.

I especially liked the seamless integration with Windows context menus. Intuitively, I right-clicked on a .rar file. I was presented with a menu that included several 7-zip options including open archive, extract files, and test archive.



I chose 'open archive' and a well-thought out and simple UI containing the .rar file was presented with just a few buttons, as well more options contained in a menu bar across the top of the application. All I needed to do was click the extract button and provide a location, and the archive file was unpacked in less than a second.
 



7-zip satisfies PD2: I was able to successfully install and use the system.

Prime Directive 3: If you were going to attempt to modify and improve the system, how easy would it be for you to do so?

The package has it’s own home page at http://www.7-zip.org, and another developer-specific page at http://sf.net/projects/sevenzip/develop.

Not only did the developer page include a link: "Send a request to join this project" but the project home page showed statistics for Bugs, Support Requests, Patches, Feature Requests, and Public Forums.

Each statistic had a link to very detailed and easy to understand data arranged in a table format. In fact, the public forums page had both a forum for help, and a forum for discussion including a useful search by keyword feature.

In addition, the 7-zip project home page contained license information, version change history, and a (favorable) compression ratio comparison chart comparing some of the leading popular archivers currently in use.


Without looking at the source code and other developer documentation (available by request only) I cannot be sure PD3 is satisfied. If the source code and developer documentation is comparable to the rest of the package, I suspect that it would be easy to modify and improve the system, thus satisfying PD3.