Tuesday, August 30, 2011

FizzBuzz Java Implementation Analysis in Eclipse

It took me approximately 25 minutes to implement (with good citizenship) and verify (line-by-line) the FizzBuzz program.  Summary: Rough implementation - 10 minutes; Code-polishing - 15 minutes

Before our first lecture class for Software Engineering, I have not programmed in Java for months. Given this task to implement FizzBuzz in Java, I took about 10 minutes to code FizzBuzz off the top of my head (and partially from what I could remember from last week) and run it with an at-a-glance "passed" for verification of correct output. However, at this 10-minute mark, I knew I had yet to appropriately verify my code, figure out how to place it in the proper Java package (edu.hawaii.ics314, in this case), and comment my code for good programmer citizenship's sake. With fellow classmate Jason Yeo's help, I discovered that I had always been missing one simple step to placing a Java source file in a custom package, and that step is to specify a name for the "Package" text field upon creation of a new Java class. As can be seen in the following figure, I had multiple packages before I made the right one (and later got rid of the others):

Figure 1: Multiple packages before creating the right one

Commenting each subsection of the code took only a few minutes.  It was the line-by-line verification of the correct output that comprised the bulk of the 15 extra minutes I spent to polish my code.  Each of the "FizzBuzz" and "Buzz" outputs were a given, since multiples of 15 and 5 are hard to miss.  In order to verify the "Fizz" multiples of 3, I mentally added each multiple's digits and divided the resulting sum by 3.  In the near future, I shall learn to use JUnit to test my code instead of this human error-prone line-by-line verification method.

In conclusion, I learned that writing the code itself is a downhill slide.  It's the uphill climb - the polishing of code and learning of new concepts to polish it even better - that takes more time, but in the end, it matters most.

Figure 2: The proper package, carefully-constructed comments, and line-by-line verification


Figure 3: My Java Implementation of the FizzBuzz Program

Sunday, August 28, 2011

Logisim: An Essential for Every ICS 331 Student

An Assessment of Open Source Software against the Three Prime Directives for Open Source Software Engineering

Last semester, I took ICS 331 with Dr. Curtis Ikehara, which is a course entitled "Logic Design & Microprocessors," and about each week, he would assign us a lab assignment using our breadboards.  In other words, understanding and building circuits was a huge portion of the class, and if only I had begun to think sooner about delving into the world of open source software, then I would have saved myself from unnecessary eraser markings and trouble.

Overview

Logisim is exactly as its name implies: a simulation of logic - of digital logic circuits, to be more specific.  Its main function is to serve as a user-friendly interface for designing, building, and simulating digital logic circuits.  More information can be found at its SourceForge.net website and Project Home website.  In reference to Dr. Philip Johnson's Three Prime Directives, my assessment of Logisim is as follows.

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

In less than five minutes, I was able to discover Logisim's most basic function without reading any tutorials by replicating a XOR circuit consisting entirely of NAND gates, as shown in the image below.  After accessing the "Help" menu, I discovered the feature of building circuits automatically using input from a truth table, which is a useful function for building especially complex circuits.  This program also features hierarchical circuit design, or the ability to use saved/already-existing circuits as portions of other circuits.  In short, this system, without a doubt, successfully accomplishes a useful task (and more).


Figure 1: XOR circuit consisting entirely of NAND gates

Figure 2: The "Help" Documentation

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

It took about a minute or so to download, install, and run the program (the latter accomplished by a simple double-click on the OR gate icon labeled "Logisim").  For download and installation support, straightforward and concise "Getting Logisim" directions are found on the Project Home website, upon clicking the "Download" link on the left panel.

As mentioned above in the first prime directive, the interface is simple enough in design that the average user can construct a circuit in under five minutes.  Click once (but do not hold down) on a logic component icon, such as a gate, move the mouse pointer over to the dotted area, position the icon, and place it down by clicking once more.  Hovering the mouse pointer over the blue markings behind a gate, for example, creates a momentary green circle around the specific marking.  This circle indicates a point from which the user can click, hold, and drag a solid line from one icon to another.  The entire contents of the "Help" documentaion for Logisim can be found offline on the "Help" toolbar within the program or online at the developer's website.  In short, this system is extremely easy to successfully install and use.

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

Bugs, Feature Requests, and Support Requests could be reported/requested using the "Tracker" menu on Logisim's SourceForge.net toolbar.  The News information under the "Develop" menu includes version release notes; the 2.7.1 entry here introduces a mailing list for development updates, which anyone can subscribe to at this link.  There is also a separate Logisim Developers' mailing list and Google Group found on the "Support" menu.

Features, bug fixes, and design changes are highlighted on Logisim's Project Home website under "Release History," and Carl Burch, the original developer, also provides his e-mail address in the "Comments" section in case the SourceForge.net resources do not serve a user's needs.

At Logisim's "Develop" page on SourceForge.net, clicking the "browse code" link under "Repositories" displays a page that shows the file/folder name, the number of revisions made to that file/folder, the "Age" (stating the elapsed time since the last revision), the "Author" (who made the last revision), and the last log comment/entry.  One way to access the source files is by clicking on the "Download GNU tarball" link.  Another way to access them is by decompressing the jar file included with the initial download of the Logisim software.

In regards to the Java source code, I feel that there is a significant lack of comments in each of the ten sample files I have opened.  Most of the comments are something along the lines of "access methods" or short three- to five-word one-liners.  Only one of the files I opened actually had a few comments within a method itself.  This style of commenting is in no way beneficial on my part or, as I can imagine, on anyone else's.  Hence, despite the fact that some pretty solid support and documentation exists for the Logisim open source software, it does not meet the last prime directive because its source files are not well-outlined and well-commented.  Nevertheless, I still recommend that every ICS 331 student take advantage of this software as soon as humanly possible.

Wednesday, August 24, 2011

Blog Title: "Geek Inertia, You're Despicable"

I spent the greater part of two hours trying to devise a creative title.  Satisfied with the results?  Yes, close enough.  This title personifies my lifelong stance on learning about IT.  Thanks, Daffy.
~ Proud [Warning: "Computer" is Inferred] Geek