Thursday, August 30, 2007

07. CodeRulerReview

For this assignment my tasks were to review Jung's implementation of the CodeRuler class and find any formatting errors that do not follow the Java coding and documentation standards. After reading "The Elements of Java Style", I learned that there is more than just inserting comments, choosing proper variable names and method names to make our code more readable.

At first sight it seemed to me like Jung did a good job in formating his code and making it readable to a reviewer. However, I found some minor and some major issues that do not follow Java Style which is alright since our class did not have the chance to read "The Elements of Java Style" before implementing the CodeRuler class. Moreover, some of the loops should include block statements to make the code more readable and easier to modify if necessary.

In conclusion, it was very interesting to see someone else's style of writing Java code and to find out potential Java coding and documentation standard errors. Finding such errors in code that was not written by me, helped me to stayed focused through out the whole review while learning the correct way of documenting Java code.

Just a suggestion, try to figure out how to use your knights to attack either the enemy peasants or the enemy knights and I am sure that you will have a greater chance of winning.

Below is a Table summarizing all the Java coding and documentation standard errors that I found in Jung's implementation of the CodeRuler class.

FILE
LINESVIOLATION
COMMENTS
MyRuler.java94, 104
EJS 6
Break up long lines

MyRuler.java32, 33, 34, *
EJS 8
Do not use hard tabs

MyRuler.java41, 48, 63, *
EJS 37
use one-line comments to explain implementation details
MyRuler.java
23
not sure
put closing '}' at newline
MyRuler.java8, 9
EJS 46
Establish and use a fixed ordering for Javadoc tags (@version missing)
MyRuler.java116
EJS 49
Omit the subject in summary descriptions of actions or services
MyRuler.java63
EJS 59
Add internal comments only if they will aid others in understanding your code.
MyRuler.java63
EJS 60
Describe why the code is doing what it does, not what the code is doing
MyRuler.java33
EJS 62
Explain local variable declarations with an end line comment
MyRuler.java108, 109, 112, *
EJS 64
Lable closing braces in highly nested control structures
MyRuler.java110, 125, 134, *
EJS 76
Use block statements instead of expression statements in control flow constucts

Wednesday, August 29, 2007

05. CodeRuler

Group members: Michal Zielinski & Chiao-Fen Zielinski-Liu

Source Code: Please click here to download

We have chosen a special strategy for our knights and peasants to follow. Fist of all the peasants are instructed to walk in certain directions as a group. This means that all peasants, rather than wondering randomly around, follow a path in any direction for a specific number of turns which makes them all walk towards one direction for a certain timespan, therefore occupying more and more land.

In the meantime the knights are instructed to find out the location of the enemy peasants and capture them as they are discovered. The knights also have a second task that is to capture any enemy object that is in the location of one square in either direction.

As this battle of occupying land and capturing peasants goes on and we inherit more and more land, we also produce more peasants as well as knights. Although, the code is written such that if our ruler has less knights then peasants, we try to create more knights.

This are the result runs:


Result 1Result 2Result 3
michalz-chiaofen vs. migrate ruler524 - 135481 - 32441 - 73
michalz-chiaofen vs. gang up ruler198 - 220512 - 302225 - 189
michalz-chiaofen vs. split up ruler189 - 221147 - 178114 - 152


Finally, the chosen strategy works well against the migrate ruler and the gang up ruler but it did not help winning against the split up ruler.

Writing this game application I used the chance to learn the eclipse platform as well as to brush up my Java programming knowledge. I have not used Java for a wile but it took not long to remember and realize all the functionalities that Java provides and which I have learned in previous classes. With the eclipse software I did not have many problems yet. However, we had to look up how to run javadoc over our files. With a little of searching on the net everything became clear and we were able to generate the needed HTML doc pages. In addition, we had some trouble with the CodeRuler game itself, when downloading it. After successful downloading of the CodeRuler zip file and proper extraction of them into the right folders, first we weren't able to see the other folder under New -> Project... . However after activating the Java Runtime environment the folder magically appeared.
Our teamwork was well. It was fun not to have to come up with a well organized strategy all by yourself. After, we plan out our strategy we thought about how to start writing the code and I must confess that if two people think about the code, it is generated much faster with even fewer bugs because the other person who is not writing code at that time has the chance to look for potential bugs. Therefore, I support teamwork at all times.

Monday, August 27, 2007

02. OSS Experience

I downloaded an open source software at sourceforge.net called Bolzplatz 2006.


Bolzplatz is a 3D soccer game in a comic style appearance inspired by the 2006 Soccer World Cup held in Germany. "This game is written in two programming languages: Java and C++. Java is used for the game engine (gameflow, artificial intelligence, game data handling, ...), while the libraries for video, audio and input are coded in C++. The connection between the Java classes and the native binaries is achieved by the Java Native Interface (JNI). Most game data is coded in XML, so it's really easy to edit it." (http://www.bolzplatz2006.de/de/development.php)

Bolzplatz 2006 is one of the best free computer games I have ever played. It definitely fulfills the first Prime Directive (The system successfully accomplishes a useful task). For instance, the user can choose any soccer nation that was qualified for the 2006 Soccer World Cup. The user has also the choice of playing a friendship game or the whole World Cup tournament. In addition, the user is allowed to change the stadiums, referees, and many other common options.

The second Prime Directive (An external user can successfully install and use the system) is fulfilled by the easy process from download till installation and pleasure. The actual download took about ten minutes. Once downloaded there is only an executable to double click before the installation can begin. The installation process is pretty smooth. Basically all the user have to do is click the next button to set up all configurations and then enjoy the game.

Finally, the third Prime Directive (An external developer can successfully understand and enhance the system) is somewhat satisfied by the documentation found at Boltplatz2006.de under technical background.




04. FizzBuzz

This is the FizzBuzz program written in Java.

public class FizzBuzz {
public static void main(String[] args) {
int i=1;
while(i!=101){
if(i%3==0 && i%5==0){
System.out.println("FizzBuzz");
}
else if(i%3==0){
System.out.println("Fizz");
}
else if(i%5==0){
System.out.println("Buzz");
}
else{
System.out.println(i);
}
i++;
}
}
}
It took me a little more than five minutes to write this program. However, I did not just start writing the code, but thought first of its implementation. Learning about Software Engineering or going into this field one must understand that before writing the code for software one must first plan it out therefore minimizing the probability of certain bugs. Since, I didn't take any courses the last semester that required me to write programs, I got a little rusty with the syntax and use of the Java programming language. I found only one mistake, that I made when I though about how to write this code, when running it in Eclipse. The initial code had this if statement:
if(i%3==0 && i%5==0){
System.out.println("FizzBuzz");
}

in an else if statement, making the output wrong.

Even though it took me as little as five minutes to write the code, I spent more than half an hour getting familiar with Eclipse, reading its documentation, and the tutorials, because I have not used this software before. After reading the tutorial I found out that Eclipse is an easy to use software with many capabilities.

Finally, it should be clear too anyone that software always will have bugs. If you don't believe me then read "Writing Secure Code" by Howard and LeBlanc. It is a very good book and I recommend it to anyone.