Wednesday, December 14, 2011

Hale Aloha CLI Technical Review Part Deux

What started as another group's system ended up as our project in a surprise turn of events. Our initial group comprised of Branden Ogata, Jayson Gamiao and myself were tasked with enhancing the cycuc's CLI system. By enhance what I mean is add more functionality to the cycuc system. The functionality added are 3 additional commands that add new features, listed below;

  • set-baseline [tower | lounge] [date]
This command defines [date] as the "baseline" day for [tower | lounge].  [date] is an optional argument in YYYY-MM-DD format and defaults to yesterday.  When this command is executed, the system should obtain and save the amount of energy used during each of the 24 hours of that day for the given tower or lounge.  

  • monitor-power [tower | lounge] [interval]
This command prints out a timestamp and the current power for [tower | lounge] every [interval] seconds.  [interval] is an optional integer greater than 0 and defaults to 10 seconds. Entering any character (such as a carriage return) stops this monitoring process and returns the user to the command loop.  

  • monitor-goal [tower | lounge] goal interval
This command prints out a timestamp, the current power being consumed by the [tower | lounge], and whether or not the lounge is meeting its power conservation goal.   [goal] is an integer between 1 and 99.  It defines the percentage reduction from the baseline for this [tower | lounge] at this point in time.  [interval] is an integer greater than 0.  

These three commands were successfully implemented, however many difficulties were had during this process. The main difficulty our group had was using cycuc's system, since we were not familiar with their code, we first had to understand what exactly does what. Perhaps there is a little bias on our part since our group structured the CLI project a certain way, but cycuc's structure of their CLI was confusing. What ended up happening was that, we made changes to portions of their code so that we could successfully implement the three new commands. We implemented all the functionalities asked and also fixed some of the bugs left over by cycuc in this current system. As with the last project, we used the Issue Driven Project Management (IDPM) principals during this project. This time we were experienced with IDPM and things went along very smoothly. Our email exchange for this implementation reached close to 100. This was close to the number of emails we sent out for our CLI system. Similar to the last project I felt that most of the principals we had done successfully. We had a very good means of communications, all of us used the build tools available to aid our development and our system adheres to all relavent coding standards.

Keeping the three prime directives in mind;

1. Does the system accomplish a useful task?
Yes, the implemented commands give meaningful data in relation to WattDepot

2. Can an external user successfully install and use the system?
Yes, the most current version is located in the downloads page of cycuc's google code page. The userguide pages located in the wiki also has detailed instructions on how to use the system. 

3. Can an external developer successfully understand and enhance the system?
cycuc has left a developers guide in the wiki page for information on enhancing the system. What we had done to modify cycuc's code was to document the system further by expanding the comments within the code. 

What I feel we learned from taking over another group's system is that to fully enhance the system on hand you must know exactly what each line of code does. The difficulties we faced was understanding the structure of the code. We all have our own ways of thinking. In essence through this project I developed my software engineering skills and skillset. 

Friday, December 2, 2011

Hale Aloha CLI Technical Review

This is a continuation of the last blog entry I've posted. Essentially the purpose of this blog entry is to detail the findings of a complete review of a software system. The system on hand is the Hale Aloha CLI system developed by Team cycuc

The following is the technical review our team put together, with respect to the three prime directives.

Review Question 1: Does the system accomplish a useful task?
Below is a sample run of team cycuc’s system:

When we initially ran Team cycuc's .jar file there was a slight problem as it could not successfully run. Eventually one of cycuc's team members had updated the system for it to successfully run in console. For the most part, this system provides functionality as described in the assignment specifications. For example, the formatting of both the date and power / energy is not in the same as the sample output given.

> current-power Ilima-A
Ilima-A's power as of 2011-11-07 13:48:56 was 2.3 kW.
> daily-energy Mokihana 2011-11-05
Mokihana's energy consumption for 2011-11-05 was: 89 kWh.
> energy-since Lehua-E 2011-11-01
Total energy consumption by Lehua-E from 2011-11-01 00:00:00 to 2011-11-09 12:34:45 is: 345.2 kWh
> rank-towers 2011-11-01 2011-11-09
For the interval 2011-11-01 to 2011-11-09, energy consumption by tower was:
Mokihana  345 kWh
Ilima     389 kWh
Lehua     401 kWh
Lokelani  423 kWh

This may be an issue for some people depending on how they plan to process the data given. Reporting the data given in units such as kilowatt may be more desired. In the case of the rank-towers command, no units appear next to the output given which may confuse those not familiar with the system. Also, it appears that for the commands daily-energy and energy-since reports the wrong units with respect to the data given. From personal experience with the getData() method, the data returned by this method must be converted correctly to M Wh. In this case, 549 kWh should be 0.549 M Wh.

For example, the formatting under the current system is as follows;

> current-power Ilima-A
Ilima-A's power as of 2011-12-01T22:56:50.337-10:00 was 6756.08 W.

Some of the commands do not successfully return data at all, below is a sample of the code when the rank-towers command was executed.

> rank-towers 2011-11-01 2011-11-09
Connected to server successfully.
Rank Towers by Energy consumed, from 2011-11-01T00:00:00.000-10:00 to 2011-11-09T00:00:00.000-10:00
Caught an exception! Here's the message: 
400: Range extends beyond sensor data, startTime 2011-11-01T00:00:00.000-10:00, endTime 2011-11-09T00:00:00.000-10:00:   Request: GET

Sorry, due to technical difficulties, the data from WattDepot has been lost, the current range of datais from 2011-11-24 to the current date. 

> rank-towers 2011-11-25
Connected to server successfully.
Rank Towers by Energy consumed, from 2011-11-25T00:00:00.000-10:00 to null
Caught an exception! Here's the message: 

Essentially the system attempts to implement the four commands listed in its help menu. The exact usefulness of this system is debatable as we deem this version of cycuc’s system not ready for distribution.

Review Question 2: Can an external user successfully install and use the system?
In addition to containing the files for hale-aloha-cli-cycuc, the project site provides a very general idea of what the project is and does.  The home page has a brief description of the system and a picture that presumably provides an explanation for the group name.  This does give viewers an idea of what the system does, but not a very clear concept.  There is no User Guide page; instead is a page titled “PageName” that contains most of the information that the User Guide should.  The exception though is how to execute the system, which is not covered.  The distribution file in the Downloads section does include a working version of the system along with an executable .jar file.  The version number is included in the distribution folder name, allowing users and developers to distinguish between different versions.  These version numbers include the timestamp corresponding to the time at which the distribution was created, thus letting users and developers compare versions chronologically.  The numbers that actually indicate major and minor versions appear to have remained at 1.0 since the first downloads became available.

The tests of the system are shown below:

Valid Input:
> current-power Ilima-A
Ilima-A's power as of 2011-12-01T23:11:50.751-10:00 was 6333.76 W.

> daily-energy Mokihana 2011-11-25
Connected successfully to: org.wattdepot.client.WattDepotClient@2be2befa
509734.840423 MW consumed on 11/25/11 

> energy-since Lehua-E 2011-11-25
Connected successfully to: Lehua-E
Source: Lehua-E      
639210.4079087041 MW consumed since 11/25/11 

> rank-towers 2011-11-25 2011-11-26
Connected to server successfully.
Rank Towers by Energy consumed, from 2011-11-25T00:00:00.000-10:00 to    
Mokihana-06-telco      15385.932595232502
Lokelani-08-telco      16653.69566474599
Lokelani-12-telco      19451.44859161321
            Lehua-10-telco      19645.025624631904

       Invalid Input:
       > current-power Ilima-z
       Caught an exception! Here's the message: 
       Invalid source: Ilima-z
       java.lang.NumberFormatException: For input string: "Ilim"

> daily-energy Mokihana 2011-11-33
Caught an exception! Here's the message: 
Invalid timestamp: Invalid day 33 days are 1 - 31

> daily-energy Mokihana 2011-11-25
Connected successfully to: org.wattdepot.client.WattDepotClient@7114460
509734.840423 MW consumed on 11/25/11 

> energy-since Lehua-L 2011-11-27
Caught an exception! Here's the message: 
Invalid source: Lehua-L
java.lang.NumberFormatException: For input string: "Lehu"

> rank-towers 2011-1124 alsdjaflakdsf asdlkfjasd;flkajs fklajsdlfk sdf;lkafj k;djf ;akdjf;lkasfajs 
jdkl;asfj s;dlfkjas ;dlkfj asdl;kfj asfl;kasdj fasdl;kf jasl;kdfj as;lkfja sd;lfkajs ;lfkjas f;lkajsdf 
asd;lkfjas l;kdfjas ;dlfkjasd f;lkasjdf;lkas jf;laksjf as;ldkfjasl ;fkjasd;lfkjas
Connected to server successfully.
Rank Towers by Energy consumed, from 2011-11-25T00:00:00.000-10:00 to null
Caught an exception! Here's the message: 
//this tests overflows the buffer

Review Question 3: Can an external developer successfully understand and enhance the system?
Next, check out the sources from SVN (read only), and see if you can generate the JavaDoc documentation.  If it can be generated, review all of the JavaDoc pages to see if they are well-written and informative.  Do the JavaDocs provide a good understanding of the system's architecture and how individual components are structured?  Do the names of components (packages, classes, methods, fields) clearly indicate their underlying purpose?   Is the system designed to support information hiding

Next, see if you can build the system from sources without errors.  See if you can generate coverage information regarding the system.   Next, review the test case source code to see how the current developers are assuring the correctness of the functionality of the system.   By combining information from the coverage tool with review of the testing source code, you should come to a conclusion about how well the current set of test cases can prevent a new developer from making enhancements that break pre-existing code. 

Now read through the source code, and check to see if coding standards are followed and if the code is commented appropriately.  Is the code easy to understand, and is there neither too much nor too little commenting? 

Next, check the Issues page associated with this project.  Is it clear what parts of the system were worked on by each developer?  If an external developer had a question regarding a certain part of the system or a certain aspect of its behavior, could the Issues page be used to determine which developer would be the best person to ask? Does the current system appear to result from approximately equal input from all of the developers, or did some developers appear to do much more than other developers? 

Now check the CI server associated with this project.  Apart from Nov 22-24 when there were known outages, did any build failures get corrected promptly?  Was the system worked on in a consistent fashion?  Were at least 9 out of 10 commits associated with an appropriate Issue?  

Carefully document the results of your investigations into each of these issues, and use the results to come to a conclusion regarding the ease with which a new external developer could successfully understand the current system and successfully contribute with the current team to enhancing it in future.

The Developers’ Guide wiki page on the cycuc project site provides clear instructions on how to build the system in Ant.  The guide also includes information on the automated quality assurance tools used on the project.  Specific information about those tools is not given, but developers are informed that the verify task will run all of the automated quality assurance tools.  A link to the formatting guidelines serves to document the stylistic rules that the code is to follow.  The Developers’ Guide does not mention Issue Driven Project Management or Continuous Integration.  Similarly, instructions on how to generate JavaDoc documentation are not available, though the documentation does appear to come with the project in /doc.

JavaDoc documentation, as mentioned above, comes with the project in /doc.  However, developers may still generate JavaDoc files through Ant or Eclipse.  The JavaDoc documentation itself tends to be well-written, though there are some questionable points and the description is somewhat sparse.  Several methods lack descriptions in their JavaDoc documentation.  There are a few contradictions within the documentation, as in where the description for the printResults method (line 28) indicates that the text printed is based on days[0] while the parameter tag for days (line 31) states that days is ignored.  However, the JavaDoc documentation did show the organization of the system, and the names of the various components were well matched with their actual purposes.  The system does appear to have been designed to implement information hiding, with the Command interface serving as an example.  

The cycuc system builds without errors in most cases.  A timeout while attempting to access the server will cause the entire build process to stop, which accounts for the instances in which the build fails.  Aside from timeouts, the system builds properly.  

The data that Jacoco provides concerning test coverage does induce some slight concerns about the validity of the testing.  The halealohacli package has no testing at all.  Testing on the halealohacli.processor package covers 67% of the code and 58% of the possible branches.  For halealohacli.command, 94% of the code was executed in testing, while 59% of the branches were taken.  (These values seem to vary upon repeated testing; this may be due to the aforementioned timeouts.)  These low values for branch coverage in particular may stem from a lack of testing for invalid input.  As a result, none of the exceptions are checked.  The tests indicate that parts of the system work for a particular input; however, as there is only one test per test class (with the exception of TestProcessor) it is difficult to be certain that the system does behave correctly.  Thus, the existing testing will not necessarily stop new developers from breaking the system; the testing ensures that developers cannot treat valid input incorrectly, but does nothing to stop invalid input from causing problems.  

With regard to coding standards, there exist several minor deviations from the standards that do not affect the readability of the code.  The amount of comments varies: at times, there is a comment explaining every line of code, while at other points there are entire blocks of code without any documentation.  The deviations from the coding standards are provided below:

EJS-07: Include white space.
There is a lack of whitespace in the test methods of TestRankTowers, TestDailyEnergy, and TestCurrentPower.

EJS-13: Capitalize only the first letter in acronyms.
HaleAlohaClientUI class capitalizes “UI” instead of only capitalizing the first letter.  Admittedly, “HaleAlohaClientUi” might have been confusing to read.

EJS-29: Qualify field variables with “this” to distinguish them from local variables
In HaleAlohaClientUI:
        prompt (line 66)
        finished (line 27)
        scanner (line 130)
In Operation:
        string (line 35)
In CurrentPower:
        powerConsumed (line 24)
In DailyEnergy:
        energy (line 44)
In TestProcessor:
        processor (lines 37, 47, 59, 60, 75, 80, 81)

EJS-30: When a constructor or “set” method assigns a parameter to a field, give that parameter the same name as the field.
In Processor:
    setSource (line 135)
    setTimestamp (line 81)
    Note though that in both of these cases the methods are not actually setting the field to the parameter value.

EJS-31: Use uppercase letters for each word and separate each pair of words with an underscore when naming constants.
In HaleAlohaClientUI: 
    prompt (line 34)
In Operation:
    quit (line 10)
    help (line 12)
    currentPower (line 14)
    dailyEnergy (line 16)
    energySince (line 18)
    rankTowers (line 20)

EJS-33: Keep comments and code in sync.
In HaleAlohaClientUI:
    “When we have the processor class implemented...” (lines 38-39)
        The Processor class is already implemented as of this writing.

EJS-35: Use documentation comments to describe the programming interface.
In HaleAlohaClientUI:
    JavaDoc comments were used repeatedly where single-line comments would have been preferable.

EJS-53: Provide a summary description for each class, interface, field, and method.
In HaleAlohaClientUI: 
    isFinished (line 26)
In DailyEnergy:
    getEnergy (line 48)
In EnergySince:
    getEnergy (line 49)
In RankTowers:
    rankTow (line 56)
In Processor:
    getTimestamp (line 179)
    getBeginningTimestamp (line 187)
    getEndTimestamp (line 195)

ICS-SE-Java-6: Format JavaDoc summary lines correctly.
In TestDailyEnergy:
    test (line 22)
        The first “sentence” in the JavaDoc documentation is “1.”  This does not adequately describe the method.

Overall though, the code is readable; admittedly, the person testing the code had already implemented the project for a separate group and thus might be familiar with the objectives of the code, which would affect the results and opinions of the tester.  

Looking through the Issues page associated with this project, it is clear what parts of the system were worked on by each developer. This team utilized a variety of status options available to better inform an external developer what worked and what didn’t work with respect to project progression. In some cases, clarification in the form of comments show the decision making process this team used when dealing with issues. Since each issue described clearly explains what the task was, it should be easy for an external developer to determine which developer would be the best person to collaborate with. In terms of work input from all of the developers, it appears that some team members did more than others.

Turning to the CI server associated with this project, it appears all build failures were corrected promptly with a maximum latency of roughly 30 minutes. Also, looking through each successful build, this team showed that they were working on this project in a consistent fashion where at least 9 out of 10 commits associated with an appropriate Issue.

Tuesday, November 29, 2011

Issue Driven Project Management

Recently I've partaken in a group project with two fellow software engineers (Branden Ogata and Jayson Gamiao) in which we developed a Command Line Interface (CLI) for energy and power consumption in the UH Manoa Dorms. More specifically we enhanced the wattdepot katas to have a more user friendly front end. This project also used many of the Issue Driven Project Management (IDPM) concepts such as breaking a project into meaningful tasks. Using IDPM really made our lives easier, since everyone had a specific job to do. At first I thought that this project would've been done faster if one person just coded everything since, he/she would know how the code worked. However I was proved wrong because each project member contributed and showed their areas of strength in programming terms.

To briefly explain what IDPM is; In software project management things can get very complex and the larger the project is the more complex it will be. Essentially IDPM has project members working on tasks, which are small jobs to complete the overall project. The project members should have a task to work on at all times and tasks should be meaningful. My overall attitude to what worked with IDPM was that it provided a framework in which group members know what to do and what other group members are doing at all times. This is evident with email notifications with each update and build tools verification.

The project implemented the following commands

  • current-power [source] Prints the current power consumption of the source
  • daily-energy [source] [date] Prints the amount of energy that the source consumed on the given date
  • energy-since [source] [date] Prints the amount of energy that the source consumed from the given date to now
  • rank-towers [date] [date] Prints the Hale Aloha towers in order of energy consumption between the dates given
  • help Prints a list of commands that the user may type in 

The functionality built in was a soft of idiot proof user interface where if users intentionally try to break the system, an error message would be printed. The functionality that was not implemented was the addition of more commands. The wattdepot API allows more commands than the 4 listed above, but for brevity sake our group chose to implement those 4 as a starting point. This project leaves room for upgrading the code, at this page.

The Google code page for this project is located here

Tuesday, November 8, 2011

WattDepot Fun

Recently I've partaken in a kata exercise using the WattDepotClient. What is the WattDepotClient you ask? Well it is basically a Java Class that holds a lot of energy data from the dorms located at UHM. The purpose of the katas was to manipulate this energy data and print the selected data. All in all I completed 5 out of the 6 katas here, due to the difficulty in some of the katas I did not have enough time to finish all of them. What was most fun about these katas was the fact that we were given a system/API and was told to understand the methods and utilize them for our kata solutions. Most likely that without access to the API, the katas would've taken much longer to finish. It took roughly a day per kata but kata 3 was most difficult in my opinion. However I had gained insight to a possible solution with the help of my fellow software engineer, Russell Vea. 

I felt that WattDepot was a excellent exercise in a sense that it provided real world data. All the data collected were actual energy/power usage from dorm rooms, and it was fun knowing that I had access to this data.   

Tuesday, November 1, 2011

Energy in Hawaii

Living in Hawaii, we unknowingly pay more for our energy use than the mainland. Coupled with the fact that our primary resource to create power is gas, we put ourselves in a situation where Hawaii is at the mercy of Gas. I know this firsthand because recently I just started to drive to school, rather than catch the bus. However as Hawaii tries to shift towards a clean energy solution, I think of all the pros and cons of this effort.

What was interesting to me was the fact that Hawaii pays around 30 cents per kWh while the mainland only pays 10 cents. This is a prime example of the 'paradise tax' we pay for living in Hawaii. Since we do not have a 'super grid' like the mainland, we rely heavily on electric plants that consume gas as a means to make energy. Keeping in mind that Hawaii is in a prime spot for other renewable energy alternatives, such as wind, solar, and geothermal. 

Energy in Hawaii is difficult to describe, but I would summarize it in one word, complacency. Most of the residents here are either unaware or don't care for the clean energy movement, and most likely they'll grumble and whine when it is too late. Hawaii clean energy initiative is a great idea but it requires a collective effort from the community. For example a small group of energy enthusiasts won't make a dent when hundreds of thousands of energy users don't preemptively change their energy usage.

I like to use the analogy of a person that thinks their actions doesn't make an impact on this situation as an example of the problem we face. If people in Hawaii don't begin to try become more energy efficient, I would ultimately be paying the price by a higher electricity bill, and paying an arm and a leg for gas. This bystander effect will be the biggest challenge that the HCEI would face in my opinion. However a lot of people are making efforts to promote clean energy in Hawaii.

For instance Jay from HNEI has received a grant from the US Department of Energy to do work using neat energy meters. These energy meters are a great tool to provide real empirical data on energy costs. For example if I installed an energy meter and suddenly realized that my energy usage has jumped twofolds just by watching tv, I would reconsider my habits to try reduce my energy usage. Hopefully this issue does find a solution to itself in the future, as Hawaii is in dire need for a clean energy solution.

Tuesday, October 25, 2011

Five Important Lessons Learned In Software Engineering

1. Why should software developers always keep the three prime directives in mind?
    The three prime directives ensures that a software system is a well developed and easily maintainable code. The three prime directives are found here.

2. The FizzBuzz program makes use of the assertEquals jUnit test cases, what would be an example test case for this program?
    Since the FizzBuzz program tests for number cases with, FizzBuzz being printed if n is divisible by 3 or 5. Fizz printed if n is divisible by 3 and Buzz if n is divisible by 5. We could use the test case assertEquals("Test for FizzBuzz", "FizzBuzz", 15) for example.

3. Before committing changes to a project hosted on google code which ant target should be run?
    The verify target should pass to ensure the next person working on the project that it is a working version of the code.

4. What kind of bugs would Checkstyle find that PMD wouldn't?
    Checkstyle would find coding standard errors while PMD would find errors that deals with the code. Such as Bugs, dead code, suboptimal code, overcomplicated expressions, and duplicate code.

5. Of the three review methods, which has the fastest turnaround?
    Walkthroughs have the fastest turnaround, minimal overhead. With little/no preparation and no formal process. The other review methods include technical reviews and inspections. Technical reviews' goals include defect discovery and ambiguity resolution. Inspections attempt to detect and remove all defects.

Thursday, October 20, 2011

Google Code Project Hosting

I've been working with hosting my Robocode robot on Google Code's project hosting site. So far my experience with it has been most satisfactory, as I was able to successfully host my distribution on Google Code and sync it with my SVN client.  I've tested the SVN capabilities by uploading all the files for my project onto the truck portion of my project webpage. The most difficult thing I had to troubleshoot was the formatting of the wiki pages to adhere to my liking. I was most surprised with the quality of hosting projects on Google Code. It was very easy to create a page and start uploading and creating wiki pages. Plus the fact that other developers are able to join the project by just adding their email makes Google Code very simple.

A link to my robocode robot I've been developing is here. Overall I look forward to using the Google Code project hosting site to work on future projects, since it is a great free option for developers.