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 http://server.wattdepot.org:8190/wattdepot/sources/Ilima/energy/?startTime=2011-11-01T00:00:00-10:00&endTime=2011-11-09T00:00:00-10:00&samplingInterval=60

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: 
null

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
Mokihana 
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    
2011-11-26T00:00:00.000-10:00
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
Mokihana  
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: 
null
//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 CurrentPower.java 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:
    HaleAlohaClientUI:
        prompt (line 66)
    isFinished:
        finished (line 27)
    promptForOperation:
        scanner (line 130)
In Operation:
    getString:
        string (line 35)
In CurrentPower:
    getPowerConsumed:
        powerConsumed (line 24)
In DailyEnergy:
    printResults:
        energy (line 44)
In TestProcessor:
    testGetSource:
        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.