Monday, November 28, 2011

Issue, fix, issue, fix,...

In my latest experience, I got to know how to work in a completely new environment-- that is, working with others rather than by myself, which I have been more-or-less doing up until now. Now, you may think, "what's the big deal with working with others? People do that all the time, even with computer-based projects." This is very true, but the question is, "are they doing it correctly?"-- as in effectively and efficiently. They may, or they may not be, but I definitely received an exposure to a great process collaborate as a team on a project involving continuously-changing code, as well as an efficient way to utilize it. The process is called Continuous Integration, and the way to use it is through Issue-Driven Project Management.

Basically, Continuous Integration (CI) keeps all the group members up-to-date on the status of the project, notifying members immediately when something is "broken", and when it is "fixed". Issue-Driven Project Management (IDPM) is exactly what it says-- it's a system for managing a project by utilizing "issues". Issues are tasks set up by project members for designated members in order to 1) make sure that members aren't going, "uhhh, what should I work on now?", 2) make sure that members aren't working on the same part of the project at the same time, and 3) keep track of who did what. For our project, we used a combination of SVN + Jenkins (CI) and Google Project Hosting (IDPM) to create a project where we implement the WattDepot application-- the same one I introduced to you last time with my WattDepot Katas.

One thing that was very nice about using Continuous Integration and Google Project Hosting was the sharing of wealth; group members could work on portions of the project that were in their respective areas of expertise, or could even help fix something that another member broke, helping that person to understand the problem and become a better programmer.

On the other hand, having multiple people work on the same project has its downsides, especially when it comes to consistency. One person's thought-process, style, and knowledge is different from another's, and the same thing can be said about coding. No two people code in exactly the same way. So while I used Regular Expressions to check if a date was valid, another person used Lists and String matching to verify the location specified. Neither of us is more correct (although speed, code-length, and accuracy might differ), and so it was extremely difficult to resist the temptation to try and correct someone else's program and adjust it to fit your own coding styles.

But overall, we were able to work together with this framework and complete this project successfully. Our product is a command line interface program that users can use to view various data from the Hale Aloha residence halls at the University of Hawaii. For now, there are 4 basic functions to view the data for-- Current Power, Daily Energy, Energy Since, and Rank Towers, but the system can easily be expanded to accommodate more in the future. Entering "current-power " and a tower name will output the latest power readings for that tower. Entering "daily-energy [tower] [yyyy-mm-dd]" (without brackets, and where yyyy-mm-dd is a date) will give the energy consumption for the specified tower on the specified day. Similarly, "energy-since [tower] [yyyy-mm-dd]" will output the energy consumption for the specified tower, but as the total consumption from the specified date until the current time. Finally, entering "rank-towers [yyyy-mm-dd] [yyyy-mm-dd]" will output a list of all the towers sorted by their total energy consumption for the interval given. Additionally, the command line interface program supports the commands "help", which lists and explains the available commands to use, as well as "quit", which is used to exit out of the program. Until the user enters "quit", the program remains in a loop, so you can keep running commands and viewing data to your heart's content.

I believe that while far from perfect, our project turned out to be one of rather high quality. Perhaps we could've structured it differently to allow for better testing, or enhanced it to make it more robust, but it does what it needs to, and is fully functional. Because we got to share our knowledge, we got to see various new methods of accomplishing certain tasks and use those techniques in our own components of the project, rather than using the same old sub-optimal ones that we have been using for the longest time. There are always challenges with working in groups, but in the end, if there are even just a few parts which turned out to be implemented in a better way due to the collaborative efforts for everyone in the group, then I think the project is successful because each member takes away something learned, and can apply it with future projects.

Tuesday, November 8, 2011

WattDepot to the Rescue!


This week, I’ll be sharing with all of you my experiences with WattDepot in the past few days. As you may already know from my previous post (and from other sources), Hawaii is not in a very good position right now in regards to energy reliance and the future prospects of its energy. That’s where WattDepot can be a stepping stone—several, in fact—to building up public awareness of energy as well as bringing Hawaii into a state of renewable energy usage rather than continued reliance on oil.

First off, WattDepot is an open-source project that uses electrical monitors to record and report data to a server, which can then be accessed through client programs and applications. Users can collect data from different locations, different time periods, and even manipulate them to get another perspective on the data, such as a sorting by consumption amounts.

Because there are so many features that WattDepot has to offer, there was only one way to tackle learning how to use the API and the many components of WattDepot-- Katas, of course! The katas I needed to implement in order to become comfortable with WattDepot were:
  1. Connecting to a server and listing the sources hooked up to it, along with their descriptions.
  2. Calculating and listing the latency (how current the data is) of the sources, sorted by increasing latency.
  3. Displaying the hierarchical listing of the sources and subsources.
  4. Listing the energy consumption of each source from yesterday.
  5. Listing the highest power consumption recorded yesterday along with the time at which it was recorded.
  6. Calculating and listing for each source the average energy consumed over the past two Mondays.
Starting off with these katas was not too bad at all, because I was using a WattDepot simpleapp as sort of a template for the first two. The part that was tricky with kata #2 was the sorting of the latency. I had to brush up on my Collections, Generic Data Types and Comparators and implement an additional class called Data to help take care of the sorting. This made this kata take much longer than I expected it to-- maybe about an hour in total, whereas kata #1 took only a couple of minutes to complete.

Then came katas 3 and 4. My goodness, were these tough for me! Without much of a template to follow, I was stuck with going out and staring at the API for several hours trying to make sense of it. I could see what I wanted with the subsources and energy consumption, but I just did not know how exactly to get it. Perhaps it is a difficulty common to most programmers, or maybe it's just me, but I tend to have quite a difficult time understanding APIs (other than the Java API). It's like, "ok, I see you, and I want to get you. But how exactly do I do that?! And what kind of data type do you return?!" I guess I've been relying on the Java API too much.. But finally, finally after hours and hours (and hours and hours) of painfully staring at the computer screen (occasionally wanting to just hurl my laptop into the wall), I was able to figure out a way to parse through the list of subsources, figure out what the hierarchical ordering is logistically supposed to be, and then implementing a way to display it in a list. Phew! That only took 5 hours! Now on to kata 4.. Kata 4 took about 3 hours to complete, because I was slightly warmed up to using the API and I had already designed a Data class and a sorting class that I could tweak just a little to get it to work with the Energy Consumption values. Figuring out the calendar dates and whatnot was a pain, but other than that, it was not too bad overall.

I was already pretty much out of time by the time I got around to finishing Kata #4, so currently I only have part of Kata #5 implemented, and I did not even get to start on the last one. It was difficult to get these katas done in such a short amount of time, especially since the WattDepot application is one that I am not familiar with, and so it took a while to even minimally understand how it works. Especially for me, because I know that I take a really long time to learn knew things, more time is always very helpful. I probably could have paced out my scheduling for this assignment a little better, but sometimes you just get really crazy days where you can't do much of anything, and that happens to everyone, so you just have to live with the consequences and do better next time.

Through this exploration, I learned a lot about WattDepot—its capabilities, its potential, and just a few of its many features. WattDepot is an extremely neat and useful tool, and it is great for many applications. I can see it being used not only to monitor and report energy consumption and generation, but also using that information to analyze what is using a majority of the energy and where. This information, as well as many other findings can be used to inspire more reserved energy usage and help solve Hawaii’s energy crisis problem. Energy data manipulation may seem like only a concern for electricians and engineers who have to set up and monitor electrical components, but it can actually be constructed into user-friendly applications to be used by anyone to visually see what they are doing to their environment and their wallets. I sure hope to see a lot of people in the near future using applications as such to really think about their lifestyles and change for the better-- for their health, their finances, and their surroundings.

Tuesday, November 1, 2011

Sustainable Paradise

     Ahh the images of Hawaii: sandy beaches, blue skies, and-- what's this? Photovoltaics, wind turbines, and other renewable energy generators? Well, not so much yet, but hopefully in the years to come, Hawaii will not only be the epitome of paradise, but also of sustainable, renewable energy. For those who call Hawaii “home”, a less expensive, cleaner, sustainable source of energy is not only desirable for economic reasons but also for aesthetic reasons, because keeping Hawaii paradise-worthy is an important aspect of pride for us who are living here.
     I know what you're thinking-- “Hawaii is such a small and isolated place. Why should you guys care about renewable energy sources? The mainland and other bigger areas use more energy, so they should be the ones thinking about renewable energy.” Well, I agree that other areas should consider using more alternative energy sources, but just because Hawaii is small and isolated doesn't mean that renewable energy should be dismissed as an option. In fact, small places like Hawaii may have more reasons to transition towards alternative energy sources than larger areas, because here we face issues such as inefficient power generation, higher reliance on oil, and therefore higher price to pay for energy.
     Due to its small size and water-delimited major land masses, Hawaii does not have the large energy “supergrids” or even “grids” that the U.S. Mainland has to manage the power generation and distribution across the land. This results in having to rely on small, inefficient mini-grids in order to get power to all residents on all islands. Because of this, energy in Hawaii costs three to six times (or even more!) the amount that it does on the Mainland. Furthermore, over three-fourths of Hawaii's energy comes from high-cost oil, as opposed to the measly one percent that the U.S. Mainland relies on as their source of energy. If we do nothing to change our energy sources, Hawaii's expensive energy cost could continue to increase as time progresses.
     Another reason for Hawaii to look towards alternative energy sources is because of the high availability of many different sources of energy. Hawaii has easy access to solar, geothermal, wave, wind, hydroelectric, and many other natural sources due to its geography. In fact, there are so many options that would yield high energy output, that the entire state of Hawaii can run completely on its own generated clean energy. With such a promising possibility, what reason is there to not switch to these alternative energy solutions?
     Unfortunately, there are some negative aspects to converting to renewable energy sources, such as having to pay to set up the facilities and switch over to them. Taxes would increase, and therefore many people may oppose this, especially if they themselves aren't going to be reaping much of the benefits directly. Some organizations are actually against renewable energy sources, due to the cultural and environmental damage that the building of the structures causes to the surrounding area. But not switching to renewable energy sources will cause even more environmental damage in the end, as greenhouse gas pollution causes temperatures and sea levels to rise, greatly impacting Hawaii's landscape. And as for the cost issue, if we don't pay for cleaner energy now, we will certainly pay for it later, in the form of not only higher fuel and oil costs, but for everyday items as well, as prices will have to increase in order to compensate importing costs.
     So there are many reasons for Hawaii to really start getting its act together and really pushing for renewable energy sources. Everyone can and must do their part in order to make Hawaii a hospitable place that can be called home even decades into the future. Conservation of energy is something we can all do to help keep energy costs down, and supporting renewable energy can help us achieve the goal of a cleaner, sustainable paradise. This is our world-- our home. We should want to keep it a place where we can live free of worry, hazardous conditions, and high costs. It is our responsibility to take action and do what is right for our future.