Configuration Management with Git

git-logoWe’ve all heard the age old adage, “Two heads are better than one” and for the most part, we know it to be true. Working in teams has its advantages; more brains yield more ideas, and more hands yield more output. However, collaboration is not without its challenges. Teammates must work hard to avoid the double maintenance problem (duplication of files that then need to be independently updated), the shared data problem (all files must be available to all users at all times), and the simultaneous update problem (changes made by one user are lost due to a simultaneous update by another).

For decades, software developers have had to deal with these challenges and as a result, have created very useful tools to overcome these obstacles. Git is one such tool.

It has been over a year since I first installed git and began using Github to host and manage my software projects. During that time I’ve collaborated with several developers on multiple projects and have never encountered any of the challenges mentioned above; Git provides mechanisms to handle each one. While I find working directly with git through the terminal to be challenging (since it can often be difficult to visualize the state of one’s repo through the textual interface), there are alternatives.  Github provides an excellent desktop application that makes common, yet powerful tasks, like branching, merging, and committing, easily accessible through a simple and intuitive GUI.

Based on my experience, I feel that these tools are an absolute essential for individual as well as collaborative endeavors.

E09: Choosing and OSS License

Many developers release software into the world as open source projects. By doing so, not only do they provide a service to the community but also allow the community to do them the service of further developing the code. This is usually beneficial for all parties involved but can sometimes lead to challenges when developers have conflicting goals. Releasing code under an OSS license can help to mitigate these challenges.

By adopting an OSS license, developers must agree to abide by a set of redistribution policies before contributing to the project. It also allows the original creator to get some credit for his/her work and helps to prevent others from claiming the work as their own.

Of the many available open source licenses available, I considered two: the GNU General Public License (GPL) and the MIT license.

The GNU GPL is one of the most popular licenses in use. Software released under this license is free to be copied, modified, and distributed in any way. The only restriction is that once software is released under this license, it (and any derivative work) will always exists under this license.

The MIT License is another popular license. It is short, simple, and permissive. It basically allows anyone to do anything to the licensed material as long as they attribute credit to the original author and agree not to hold him/her liable for damages or any other liability.

I think people work best when they are unrestricted. I also think that rules that govern people’s actions should be simple. For these reason, the open source code I produce will be released under the MIT license.

E08: Learning to Ask Smart Questions

In his article “How to ask questions the smart way,” Eric Raymond provides guidelines for seeking help from the community in online forums. Essentially what it boils down to is this: do your due diligence before asking others for help, then when you do ask, be concise, detailed and courteous.  Questions that abide by these rules are more likely to get a useful response from the community.

Below I’ll describe a “smart” and a “not so smart” question found on Stack Overflow and the community’s response to them.

A “Smart” Question:

An example of what I thought was a smart question can be found here and is described as follows:

Title: “Using java.net.URLConnection to fire and handle HTTP requests?”
Body: Use of URLConnection is asked about pretty often here, and the Oracle tutorial is too concise about it. So how do I use it to initiate and handle HTTP requests? Are there other hits, and “best practices” for this, that may be useful?

The title of the post names the technology involved and clearly states the problem. In the body of the post, the author makes it known that not only is he familiar with the questions posted on the forum (indicating that he may have already searched the archives for a similar question) but that he has also completed the Oracle tutorial. This shows that he has tried to find the answer himself and is asking the community for help as a last resort. Finally, he concisely restates his objective.

The responses this question received are astonishing! The highest rated answer is extremely detailed, discusses 13 different topics and provides example code. The other answers appear to be helpful too as they’ve been upvoted by dozens of users and also provide or link to code.

A “Not So Smart” Question:

An example of what I thought was a “not so smart” question can be found here and is described as follows:

Title: “Java: NoSuchElementException, help!”
Body: Looking for help with the following code…
<…the users code…>
Upon running, i get this exception…
<…exception details…>
Is this a file error? Have tried multiple fixes but still stuck.
Thanks.

There are several things about this post that violate the guidelines of asking smart questions. First, the title is not meaningful and does not tell the reader anything about the problem other than the fact that an exception has occurred. Second, the article suggests that when posting code, you provide a minimal bug-demonstrating test program. The author of this question posted his entire program (nearly 50 lines of code). Third, the user ventures a guess as to what may be causing the error. According to the article, your guesses should be kept to yourself (“If your diagnostic theories were such hot stuff, would you be consulting others for help?”). And finally, although the author mentions that he has tried multiple fixes, he does not say what those fixes were.

The accepted response is exactly what Raymond says you can expect to receive when asking “not smart” questions.

“As a beginner in a programming language, you need to learn how to use the documentation and resources made readily available for that language.”

The hacker then went on to pinpoint the cause of the exception but continued to stress the importance of reading the documentation.

In my opinion, the reason for the error was actually pretty easy to spot and anyone with a basic understanding of Java could have identified the error but because the question was poorly written, in a community with hundreds, maybe thousands of competent Java developers, only about 5 were willing to help.

Conclusion

I think the most important thing to remember when asking for help online is to be respectful of the other person. Keep in mind that those that respond take the time and expend the energy to do so not because they have to, but because they want to. By following Raymond’s guidelines to asking smart questions, you’re guaranteed to convey this respect.

E07: Spring-Loaded and the Three Prime Directives

One of the greatest things about our field is that there are so many people turning their ideas into useful code and making it available to the world in the form of open source software. But the effort of writing that code could be for naught if users don’t use it and developers don’t develop it. Thankfully, there are guidelines that when followed, minimize the chances of ending up in this predicament. These guidelines are known as the Three Prime Directives for Open Source Development.

Today, I’m going to look at Spring-Loaded, an open source program that enables live reloading of class files in a running JVM, and determine how well it meets the three prime directives.

Prime Directive #1

The first prime directive is that the system must successfully accomplish a useful task and I think Spring Loaded does this.

We all know that writing and debugging code can be difficult and any tool that can aid us in this process is a valuable asset. In a previous post, I talked a little bit about one such tool called LiveReload and how its changed the way I develop websites. By detecting and immediately displaying changes made to html and css files, LiveReload makes my modifications visible in near realtime. This allows me to quickly evaluate each change and decide on the subsequent action without the interruption of having to reload the browser manually. LiveReload is a valuable tool that has increased my efficiency and productivity.

Spring Loaded is like LiveReload except that it works in the JVM instead of your browser. Spring Loaded monitors your java class files and incorporates any changes you’ve made into the running JVM. In the same way LiveReload can increase a developers efficiency while creating websites, Spring Loaded can increase efficiency when developing java applications.

By delivering on its promise of dynamically loading modified java class files without the need to restart the JVM, Spring Loaded meets this directive.

Prime Directive #2

The second prime directive is that an external user must be able to successfully install and use the system.

There is no installation process as Spring Loaded is distributed as a java jar file. Enabling it is straightforward and accomplished by executing the following command in the terminal:

java -javaagent:<pathTo>/springloaded-{VERSION}.jar -noverify YourJavaClass

The developers don’t provide a lot of documentation on the installation and usage of the tool but I suspect that this is because, from the developers perspective, both of these processes are easily accomplished.

I, however, discovered two caveats that I think would be useful for users to know prior to using Spring Loaded. The first is that the code needs to be manually compiled before Spring Loaded will recognize and reload the class files into the running JVM. The second is that it seems that any class in the java file containing the main method cannot be dynamically reloaded. All additional classes must be implemented in their own .java file.

In my tests, I created two classes: SpringLoadedTest and Printer. The Printer class contained three methods, printNum() which printed digits 1-5, printChar() which printed characters a-e, and print() which was called by the SpringLoadedTest class and called either printNum() or printChar(). During execution, I alternated between calling printNum() and printChar() in the print() method and this change was reflected in the running JVM.

Changes to java class files are live reloaded in the running JVM.

Changes to java class files are live reloaded in the running JVM.

Once these two caveats are understood, using Spring Loaded is simple but a beginner may abandon the system before ever reaching this point.  Therefore, due to lack of sufficient user documentation, I believe Spring Loaded fails to meet this directive.

Prime Directive #3

The third and final prime directive is that an external developer must be able to understand and enhance the system.

Although the developers make their code available on Github and encourage people to fork the repo and submit code for consideration to commit, there is no resource to guide new developers through the architecture of the software. There’s no website, no discussion group, no youtube channel, etc. Developers interested in contributing must download the code and make sense of it on their own.  For this reason, Spring Loaded fails to meet the third prime directive.

Overall, although Spring Loaded failed to meet 2 of the 3 prime directives, I think it is a useful tool and will continue to use it when developing java applications.  Perhaps, with enough time and use, I could be the developer that commits the code that brings this open source software to achieve the two failed directives.

E06: Advanced Software Engineering

I recently began my third semester as a masters student in the Computer Science department at the University of Hawai’i at Manoa. I’ve taken many courses over the last several years; most were fun and interesting, others not so much, but there have only been a few that I feel really required students to actively participate in what they were learning and pushed us to perform at our peak. Dr. Johnson’s Software Engineering courses (I and II) are two such courses. So when I learned that he would be offering a graduate level Software Engineering course, I knew right away that I wanted to enroll.

Having already taken two semesters of Software Engineering, my hope is that this course will help to reenforce concepts I’ve previously learned, remind me of the things I may have forgotten and teach me new sets of skills to build better software. Some of the skills I would like to develop this semester include becoming better at writing correct and efficient code quickly, ensuring the production of quality applications by implementing automated testing, and become better at communicating and technical writing.

In addition to all of the above, I also hope that we’ll be able to cover topics including what constitutes good software design; best practices for writing code that may be seen and modified by others; and writing, using, and contributing to opensource code.

Based on my experience in Software Engineering I and II, I’m expecting to learn and do a lot in this course and I am excited to see what we will be able to produce at the end of the semester.

Hackaday

Fresh hacks every day

Slashdot

Professional Portfolio