Friday, August 31, 2007

7. CodeRulerReview

For this review I looked at Paul Ching's CodeRuler implementation.


Discrepancies noted from Elements of Java and in-class format:

FileLine(s)ViolationComments
MyRuler.java1ICS-SE-Java-2Do not use * in import statements
MyRuler.java112, 113, 114EJS-25Use lowercase for the first word and capitalize only the first letter of each subsequent word that appears in a variable name.
MyRuler.java77, 94, 95, *EJS-8Do not use tabs.
MyRuler.java132EJS-66Null statement - maybe this block should've just been omitted?
MyRuler.java149, 164, 184, *ICS-SE-Eclipse-2Right curly brace should be on same line as if statement


Other notes: I think the code looks pretty presentable aside from the notes above, or at least better than my code. Strategy for knights is acceptable; peasants could use improvement, but strategy is probably OK since it did fine against the bots.

One more note, is only the first castle commanded to produce knights? I'm not sure what the other castles would produce.

Other than this, it looks fine to me.

Wednesday, August 29, 2007

CodeRuler

Members in group: Myself (Andrew Wong)

Code: http://www2.hawaii.edu/~wongandr/coderuler-wongandr.zip

Strategy: Suicide. Really.

Its a crazy strategy. Right off the bat, all knights are instantly set on capturing the closest castle to the starting gate. A few things can happen from this:

- If the knights die and the castle isn't captured, I'm screwed. Good game.
- If the knights managed to capture the new castle, well, thats usually better ^^

Knights don't care about capturing any other pieces until all castles are owned by this ruler. This is risky since that might never happen, but if it ever does, its usually hard for any other team to recover.

Peasants, on the other hand, move somewhat intelligently. They will try to first claim land that other people have claimed, then unclaimed land, and then last resort to a random movement. However, if an enemy knight is chasing them, they are very good at giving them a runaround, especially if the knight continues pursuing them. But this is good, since if the knights are chasing the peasants, that leaves their castle defenses wide open... ^^

But yea, generally peasants are pretty good at covering 90% or more of the map if they ever manage to eradicate the opposition.

Results of running against sample Rulers:












RunMy ScoreOpposing Ruler Score
Migrate 18221
Migrate 28240
Migrate 38240
Gang Up 1758188
Gang Up 2788108
Gang Up 3639296
Split Up 1775106
Split Up 2761140
Split Up 3697126


Lessons Learned: A lot. I'll go by each item here.

Eclipse: Eclipse is very useful even for a person (like myself) who isn't very accustomed to Java. It has many things that help a programmer, such as "correct formatting" (e.g. after you copy and paste something in, it fixes up the spaces), function autocomplete, brace autocomplete (which is annoying at first, but you get used to it), error highlighting in the right hand side of the window, etc. The list goes on. Unfortunately, theres a performance tradeoff, but its bearable in most cases.

CodeRuler: Working with legacy code can sometimes be a hassle. It is probably very possible to redo everything without casts and using the Vector class; however, because of the way the application was developed, "you're stuck with what it was initially implemented in". (Or whatever Dr. Johnson's line was)

Java: Java is a language I'm starting to like a little more each time I program in it. True, it probably won't outdo C++ for me (since Java still has a performance overhead compared to C), but I'm starting to get used to some of my initial gripes about Java (long references such as System.out.println, performance overhead, awkward method of naming classes, etc).

Working with another person: I cannot comment on this. Actually, I can, but it would be making stuff up.

Saturday, August 25, 2007

Open Source Software Experience: Shoddy Battle

This is a writeup for the assignment described at http://groups.google.com/group/ics-software-engineering-fall-2007/web/a-02-oss-experience

For this assignment I looked at Shoddy Battle. It can be found at http://sourceforge.net/projects/shoddybattle/ with the main site at http://shoddybattle.com and contains two parts:

- a client, and
- a server.

Introduction

Pokemon is a popular game amongst millions of people around the world. One of the problems with this game, though, is that the process of raising Pokemon to battle with is often a long and tedious task. It usually takes a couple of hours to raise and level them in a desired manner, and in many cases a person realizes 'improvements' that can be done which causes them to raise another one of the same type. Couple this with a team consisting of six of these 'Pokemon', and you can see how raising a team would take a while.

Pokemon's battle system is basically a larger version of rock-paper-scissors - much like CodeRuler, one strategy can defeat another but lose to a third one. One of the aims of Shoddy Battle is to allow people to battle Pokemon (which they define) online with other people, allowing them to test their 'team' before actually investing the time in-game.


Installation

Installation is easy. You download the .jnlp file which runs it as a Java web app.

Ummm, wait. There's nothing to install? Thats right. Actually, if you want to run a server, there is a separate download for that too (which I did try and download, but did not want to set up). But there are advantages and disadvantages of running it as a web app:

Advantages:
  • Shoddy Battle is a network application. Network applications tend to have synchronization problems when they are updated and people use older versions. By running it as a web app, the version is updated automatically every time the program is executed. Also, one disadvantage of Java Web Start is you kinda need an internet connection (I think), but you need one anyways for this game ^^
  • Assuming Java Web Start is a good interface (which is a religion question), its easy for users to run it.
Disadvantage:
  • Ummm, where's my app? And what am I going to show for it in this writeup?

Prime Directive 1. The system successfully accomplishes a useful task.

Yes, its a fun way to play online and test teams out. But moreso, theres a few teams I have tried which have gotten horrendously slaughtered online (don't ask), and then I learned that those teams aren't really feasible. So it did help me save a few hours of training, at the very least.

I'd say its useful.

Prime Directive 2. An external user can successfully install and use the system.

I think an external user can install the system also. Unfortunately, it comes with a hitch. This assumes the system is configured to handle Java web applications, which on a previous computer I used it didn't work completely. Maybe it was a configuration error on my part. Anyways, assuming that works fine (which I'd say is true for most systems), I'd say an external user should have no trouble installing it, especially if they go to the homepage (http://shoddybattle.com) and follow the directions from there.

Prime Directive 3. An external developer can successfully understand and enhance the system.

Luckily, there is a source package on Sourceforge. Unfortunately, I haven't tried enhancing the system. There are two main reasons I see for enhancing the system, however:
  • Security issues. If the server ever gets hacked into, there may be issues that need patching. (Then again, its only a game.)
  • Game updates. Whenever a new version of Pokemon comes out (currently it is on 4th generation - RBY, GSC, RSE, and now DP), new pokemon species and moves are added. These moves look like they're implemented in a Java file that can easily be updated when the time comes. However, it looks like they're also implemented in a database file, so it might be a little confusing where exactly the update would be. (I haven't looked into species)
Thus, I think there might be a few difficulties if an external developer were to develop the program. Then again, it would affect the overall client-server infrastructure.


Conclusions

In conclusion I'd say its a pretty fun and straightforward package for an average user to download and run, but working on it could be a challenge since it doesn't seem straightforward as to what exactly is to be modified.

Wednesday, August 22, 2007

FizzBuzz

The Problem: Write a program that writes out the numbers 1 to 100, one on each line, replacing multiples of 3 with "Fizz", multiples of 5 with "Buzz" and multiples of both 3 and 5 with "FizzBuzz".

A summary of the events while coding is as follows: (timestamped)

- Started at 9:20:35 pm.

I'm not a Java coder. I'm more used to C/C++. Luckily C and Java are very similar. Unfortunately, there are a few syntactical changes between the two. The main issue with me was researching how to write the main function (which I'm pretty sure I got wrong during the in-class exercise).

I know, I could have used the Eclipse IDE to fill in this line for me, but I already feel like a bad enough cheater for being given the "class FizzBuzz" line for free.

So I open up Google and find out what the syntax for the main function is.

- Finished researching syntax at 9:22:11 pm.

The coding begins. For the most part, syntax highlighting is the same as when I would edit source files in Notepad++ (which I like very much). The only part I do NOT like is that it automatically fills in a ending brace whenever you open one. I'm just accustomed to typing in the closing brace immediately after typing the opening brace.

On another note, I think you can get away with writing the program without any braces at all, maybe. But when I open a brace, I usually do it because I expect to have more than one line. Also, I think not putting the braces can increase the difficulty in reading the code, since then the reader must look for the implicit braces.

- Finished first coding iteration at 9:23:33 pm.

Will it work? It takes a few seconds to find the save (e.g. compile) button, as well as the run command (buried in a few menus... good thing I ran through the tutorial!). So the output appears and I proofread it.

It looks fine.

- Finished (after verification) at 9:24:18 pm.
Total time: 3 minutes, 43 seconds.


Other comments: Opening the Eclipse editor takes a while. If you want to account for that, add another 1-2 minutes to my time. I started from an already open Eclipse.

I think my time is too suspiciously fast, but maybe thats because I've had the problem statement for a while (e.g. ever since it was mentioned in class on Monday), and I have had a lot of time to think about it. If I were to do it impromptu, I'm pretty sure I would not do it this quickly.

Also, I did acknowledge that Java syntax isn't exactly one of the things I can recall offhand, and I'm still pretty surprised that didn't take up too much time.


Insights into software engineering/this class: Adding the factor of time does have an effect on how nice (or not nice) the final code works. Also, having to create a project from scratch can be something people don't do very often, which makes it more difficult to do when you actually have to write something from scratch.

Also, getting used to a new IDE does take time, which sounds like a line I heard, along the lines of "employees on a project only really start being useful after 3 months". (don't quote me on that, it's not the exact line)


- Andrew


Source listing: (in all the glory of bad indentation and line spacing - finishing quickly is a priority in this assignment, and I know tabs look ugly)


public class FizzBuzz {
public static void main (String[] args) {
for(int i=1; i <= 100; i++) {
if (i % 15 == 0) {
System.out.println("FizzBuzz");
}
else if (i % 5 == 0) {
System.out.println("Buzz");
}
else if (i % 3 == 0) {
System.out.println("Fizz");
}
else
System.out.println(i);

}

}
}

Monday, August 20, 2007

A Post!

A software engineering blog!

Weeee.....