Wednesday, August 31, 2011

Back to the Basics: Eclipse & Java

After a lengthy hiatus from programming in Java, I was given the task of implementing the Fizz Buzz program in Java (using Eclipse as my IDE) as a refresher to get me back into the swing of programming in the language. For those whom the Fizz Buzz program eludes, it is a program that should print out all of the numbers from 1 to 100, one per line, except that when the number is a multiple of 3, it prints "Fizz", when a multiple of 5, it prints "Buzz", and when a multiple of both 3 and 5, it prints "FizzBuzz". No doubt an easy program for a refresher, no?


I'll admit while it was easy to implement, it took me quite some time to do it, 14 minutes to be exact! Here are some screenshots of my code, the first being from within my workbench in Eclipse:
Despite both the ease of the program and the time it took for me to implement it, most of the time I spent was using the JUnit tool to verify my program's correctness. Of course I could have written another class, perhaps naming it something intuitive like FizzBuzzTest, that would ensure the behavior of my program to be correct under the set conditions, but I wanted to be adventurous and try to use JUnit to create a JUnit testcase to check my program's correctness. After never having the experience of using it and seeing a demonstration of it and how it can be used in a class of mine, I was determined to use it, even for such a small task as this one. I convinced myself this would be just a sample, an experience I could look back on and say, "Oh, that where I got my feet wet." Here is another screenshot of my code, this time of the test the I created using JUnit to check if my getResult() method of my FizzBuzz class worked correctly:




I was glad to see that my code worked as intended and that my JUnit test case verified this. In spite of that, the most difficult experience I had was following the model of using JUnit from the demonstration I mentioned earlier since what I could recall of the model was hazy on the details. Specifically, I was having difficulty remembering things like what return type I should make my getResult() method so that it would be easier to test using the assertEquals() method in my FizzBuzzTester class and also the parameter types of the assertEquals() method. But after some note taking, I was able to fill in the missing gaps from my recollection of the model and successfully implemented my FizzBuzzTest program with desired results. All in all, I had a fun time playing around in Java again and learning a few new tricks while doing so. I wonder what is next for Java and me in the future? 



Monday, August 29, 2011

iAlertU: A closer evaluation

Have you recently bought a new MacBook? If you have, of course one of the last things you would want to have happen is for it to get stolen. That is where iAlertU comes in! iAlertU is an open software program that has the functionality of an alarm system, relying on built in motion detection sensors  to trigger an alarm and the iSight to capture the image of a thief and sending the photo of the thief automatically. But when evaluating it against the three prime directives, how does it hold up?

  • Prime Directive #1: The system successfully accomplishes a useful task.
                 This application was fairly easy to install and run. After downloading it and extracting the application to my applications folder on my MacBook, I launched it and tested it by having it send me a dummy email, providing me with a response similar to what would be sent if it were an attempt by an actual thief stealing my computer. After getting the email, and verifying that sends pictures of both the desktop at the time and of the thief (played by me), I can say that this system does indeed accomplish a useful task.


  • Prime Directive #2: An external user can successfully install and use the system.    
                Starting with downloading the application, I would say a total time of five minutes elapsed in order for me to extract the application from the zip file to my applications folder and configure the application to send me the test email, demonstrating its functionality. As I mentioned above in the first prime directive, it is fairly easy to install and launch; It's just a matter of a small number of clicks ofthe mouse!


Prime Directive #3: An external developer can successfully understand and enhance the system.             
      Since documentation for support was supplied, I think this system can be successfully understood by any developer looking to fix bugs or seek feature requests. However, from a source code perspective I think there is an imbalance in the number of source code files where a developer can understand the code simply by reading the comments. For some of the files it was easy for me to follow along, but for others I really had to stare at the code and wonder what is was doing. I was grateful that documentation was supplied!


  Links:
  sf.net/tracker/?func=add&group_id=198330&atid=965045 (Support)
  ialertu.sf.net (Project home)
  http://sourceforge.net/projects/ialertu/files/  (Downloads)