Monday, October 26, 2009

Smart Grid: WattDepotCLI Elua Branch

Today is the start of a new project and it is getting me excited. My partner Kevin Chiogioji and I are creating a CLI (command line interface) client to interact with data from the Oahu, Hawaii smart grid. This will enable us to monitor energy usage and other data related to the wattdepot project.

"WattDepot is a RESTful web service that collects electricity data (such as current power utilization or cumulative power utilization) from meters and stores it in a database. The data can then be retrieved by other tools for visualization and analysis."

Once the command line is done we will be creating a web application to allow the users to monitor information about their consumption of energy in order to create awareness of how much energy is being consumed.

I found a small bug in jar.build.xml that incorrectly specified the output zip to be wattdepot-clientlib.jar where it should have been wattdepot-lib-client.jar. We also modified the dist.build.xml file as to build unique distributions in zip format to distinguish our branch from the others.

Our branch repository is located here:
WattDepot: Elua Branch.
Our distribution (although only now a bootstrap) is located here:
WattDepot: Elua Branch Distribution Download.

Sunday, October 18, 2009

Midterm Questions

Q. Explain how it is or how it is not possible for an individual like yourself to make money from FOSS (Free Open Source Software).

A. It is not only possible but many people are doing this now. We can think of two likely situations of this. First, is that a developer can be hired by a company to work on code to add features or modifications to meet the requirements of the company. Second, companies like IBM and RedHat pay their employees to improve software like the Linux Kernel so it can improve the companies service offerings.

Q. Why are comments and documentation so important in the success of your project?

A. Not putting comments or documentation will typically result in a failure of your project by going directly against what the second and third prime directives state. The first prime directive will also fail because if the user and developers can’t work on the code easily, then the system will not meet the functionality that was initially stated.

Q. Implement the foreach construct in a main method and give an example of class signature that is required for the use of iterating over that collection. The iterable type is arbitrary.

A.
class FibonacciSequence implements Iterable {
...

public Iterator iterator() {
return new FibonacciIterator();
}

public static void main(String argv[]) {
FibonacciSequence fib = new FibonacciSequence();

for (BigInteger i : fib)
System.out.println(i);
}

Q. Give an example of unitasking. Think creatively.

A. An example of unitasking would be if you had many things to do and you are able to organize those tasks into one specific task to accomplish them all. For example, if you have many classes to write, you could make a super class in order to save time from repetitive tasks.

Q. What are some benefits of Static Analysis and Dynamic Analysis, list tools used to perform these automatically and explain how the two types differ.

A. Static analysis can find bugs in binary, byte code or source files that may not be executed during dynamic analysis. Dynamic analysis, having to run the code, will only find bugs that are executed.
PMD, FindBugs and Checkstyle are all static analysis tools.
JUnit is dynamic analysis.

Q. Why is it a good idea to make sure the version of a required dependency that Ant retrieves is correct?

A. It is very important that all users be using the same dependancies in order to limit the scope of variables that could be causing bugs within a given package. If all packages are the same and many users report the same problem, it is that much easier to figure out the problem.

Q. Explain the importance of regression testing and its role in large systems.

A. Regression testing is essential if you do not want to have spaghetti code that is littered with bugs. Regression testing is especially useful when dealing with large systems because when many people are working on the same code, bugs can be introduced at anytime. Doing regression tests every build can prevent conflicting behavior introduced into the code during nightly builds.

Q. Give two scenarios where white box testing is beneficial and where blackbox testing is beneficial.

A. White box testing can be more detailed in its findings if it is done correctly all the down to the unit level. The problem with this is that white box test may not test for the right things or integrate with the system well. White box testing should be employed in a fashion that exhibits well thought out and reckless behavior in order to break the system.
Black box testing should be performed to see if all the components fit together or in a situation where you want to feed arbitrary data into a complete running system to see how it behaves. The system should be tested with a fuzzer in order to find bugs in software that does not handle the input correctly due to improper validation.

Q. Give some problems that version control set out to address.

A.
The double maintenance problem (having multiple copies to maintain)

The shared data problem (multiple developers need to access one file at same time)

The simultaneous update problem (a way to prevent one file by being updated at same time by multiple parties).

Q. Why is Git so beneficial for large open source projects?

A. Git allows everyone to work faster and have copies of the whole repository, instead of relying on bandwidth from a centralized location. Having the complete history one command away is power to the developer.

Sunday, October 11, 2009

Robocode is Now Available Through SVN

I have posted flankbot on Google Code. All you need to do in order to play with flankbot is install ant and read the instructions on my Google Code site. The UserGuide wiki will give you instructions on how to install flankbot using SVN. I also added a Google Discussion group for flankbot. There are some issues to be resolved with receiving automatic svn updates to the discussion group so I suggest following the latest releases with the RSS or the ATOM feed located on the flankbot Google Code site until this issue is resolved. Currently they are only taking manual requests for automated updates.

I really enjoy working with subversion and I am excited about working in a group with this tool. I have worked on another project using Google Code called tweetx, so this was nothing new, but nevertheless, Googles simple applications make life more enjoyable.


Wednesday, October 7, 2009

Quality Assurance Testing

Creating behavioral, acceptance and unit tests is time consuming and not a whole lot of fun, but it does pay off. I created six tests for my Robocode robot FlankBot to create somewhat of a benchmark. This will be useful to me when I start changing the code for my robot. Reason being, if I make changes and it does not pass these benchmarks, then I know that I must of done something wrong and I should then go back and investigate it.

The test I created test the following:

Test if FlankBot flanks most of the time.
Test if FlankBot has good survivability techniques.
Test if FlankBot can continually beat Walls (a hard bot to beat).
Test if FlankBot can continually beat Corners.
Test if FlankBot can avoid being rammed into.
Test if FlankBot has good shooting accuracy skills against Walls.

I have to say the most time consuming part of this was getting Eclipse IDE to work with Ant. There really has to be a better way to make them work together smoothly. Importing projects and getting JUnit to work as well seems a lot more hassle then it needs to be. At this point I am missing Make and VIM. I will continue looking for a better way to improve these oddities and various problems with importing other peoples projects as well.

Most of the tests I was able to perform were centered around behavioral tests. Unit tests seemed somewhat counter intuitive to the way my bot was designed, but if you can think of a way to make it work after looking at FlankBot, I'd love to hear it. If I redesigned my bot to have explicit movement methods, it would of worked better for the unit tests. All in all, it was a good learning experience, but took a little more time then I thought it would take, as there is more building and test code to work with then there is actual robot code.

Last but not least, I'd like to mention the tool EMMA. It is a code coverage tool, which does exactly what it says. It checks how much code your JUnit tests covered. I found that my code coverage is not as high as I hoped for. This is most likely because I have a few methods that are not fully implemented yet and have yet to be used.

The lessons I learned the last few days with build code will have a great effect on larger projects and alleviate a lot of the frustrations that come with it, there is no doubt about that. I am looking forward to seeing how this scales and incorporating more tools to my reserve.

Download the latest version of FlankBot with Tests here