Sunday, September 16, 2007

10. Stack

Source Code: Please click here to download

This assignment was not as easy as it seems when reading the assignment instructions. Various tasks had to be mastered in order to complete this assignment including learning the Ant build system as well as several Java automated quality assurance tools. Personally, I was glad when at the end all the specified tasks were successfully working.

I have encountered a few major problems while I was working myself down the instruction list.

problem - 1
I was able to download and install SCLC Code Size Counter correctly, however when I tried to invoke it via command line it gave me an error. It turned out that I did not have Perl 5 installed on my machine.

solution - 1
I downloaded ActivePerl and the problem was resolved. At this point I was able to execute all the targets in Task 1 but verify, without errors.

problem - 2
Another problem that I ran into was associated with javaNCSS. The download and installation were rather easy but I found the actual instruction on kclee.de a little difficult to follow. However, the actual problem was that I had to learn how to write the build.xml file for javancss.build.xml, which was a little more challenging than all the previous tasks since I did not write any XML before. Fortunately, I know HTML which did help a little.

solution - 2
In order to complete the required tasks for the javancss.build.xml file, I looked at and studied all the other build.xml files that are included in stack-5.0.909.zip. In addition, I used Google to search for related topics.

ANT vs. MAKE


I remember writing several MAKE files and having the "tab" problem because it is necessary for MAKE to have proper indentation. When working with ANT I did not have this kind of problem. However, in order to write the necessary files for ANT tasks I was forced to learn XML. After all, I believe that ANT is a more powerful tool and when allowed I would chose it over MAKE. On the other hand, knowing a scripting language such as XML is very important for the future.

SCLC vs. JavaNCSS


Both, SCLC and JavaNCSS can be used out of an ANT build.xml file. Currently, SCLC supports 27 different file types while JavaNCSS is designed specifically for the Java programming language. (I believe) Therefore, JavaNCSS looks more at packages, objects, and functions while SCLC looks at files with various extensions and concentrates on lines, comments, etc. JavaNCSS provides the number of javadocs generated whereas SCLC gives an overview of the number of files with different file extensions, and much more. Therefore, I believe that both are good tools but most powerful when they are used together on a project.

Conclusion


This assignment, as many other ICS-projects, was time consuming. Therefore, it is important to allocate enough time to be able to learn all the useful tools. At first, this assignment may seem a little difficult, however after mastering all the basic readings on all the tools involved, it is rather understanding than confusing. Finally, it would safe me a lot of trouble in my previous programming courses, when I would be aware of these open source Java automated quality assurance tools.

Wednesday, September 5, 2007

08. CodeRulerRedux

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

Source Code: Please click here to download

This time we had more time to think about a better strategy for our CodeRuler project. After reading other classmates' code we found a better way to claim land. Jared has an interesting loop in his CodeRuler code that loops through the whole grid starting in the left upper corner. We implemented a similar strategy. However, we divide the grid into four equal squares and assign peasants to each square. Since the fourth square gets less peasants and therefore they cannot finish claiming all the land, once the peasants in the first square finish claiming the land we assign them to help peasants in the fourth square. In the meantime, our knights are instructed to capture all castles that we don't own and anything that is in their way. After that the knights will capture all enemy peasants. When all enemy peasants are captured the knights go on to capture the enemy knights. We instruct our knights to capture all the castles first in order to be able to create more knights when needed in the battle with other knights. Therefore, peasants are only created when we have twice as many knights as other knights or when we don't have any peasants. This strategy works out pretty good against all the sample rulers. We were also able to include Java Documentation and Coding Standards in our CodeRuler source code which makes our code more readable and understandable to another reader.

This are the result runs:


Result 1Result 2Result 3
michalz-chiaofen vs. migrate ruler854 - 0
827 - 1
833 - 0
michalz-chiaofen vs. gang up ruler782 - 184
784 - 140
553 - 399
michalz-chiaofen vs. split up ruler725 - 256
733 - 230
748 - 182

Writing this code gave me a chance to become more familiar with the Java Documentation and Coding Standards which I learned by reading "The Elements of Java Style". I must say that it is not very easy to follow exactly what the book says since it doesn't have enough examples of certain rules. Hopefully, as this class goes along, I will be able to write code with perfect documentations.

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.