Monday, October 19, 2009

Quicky Questions

Midterm is coming up! What could be on the test? Here are some questions that ask what we have learned so far.

1. As a programmer, why is the code "import java.util.*" not something you should have in your code?
You want to let the viewer to be able to understand and trace every part of the source code.
By using a wildcard, this makes the viewer unable to help resolve issues, if there are in
your code, because the viewer does not know what you imported.

2. Why is a FizzBuzz program being used as an entry question to any programming job?
There are people who know a whole lot about programming, but not a lot about writing
source code. FizzBuzz weeds out those type of people at a programming job interview.

3. What is it called when someone watches tv, checks their phone, checks their email, checks their myspace, and trying to do their programming all at the same time? As a programmer, why is this bad?
Multi-tasking. For a programmer this is bad because their focus is not 100% on their work.
If a programmer does not have full focus on their work then the code will not have high
quality also.

4. Write a FizzBuzz program, but instead of using for loops and while loops, do it recursively.
public class RecursiveFizzBuz {
private static int x = 1;
public static void main(String[]args){
recursive();
}
public static void recursive(){
if (x != 101){
if((x % 15) == 0){
System.out.println("FizzBuzz");
} else if ((x % 3 )== 0){
System.out.println("Fizz");
} else if ((x % 5)==0){
System.out.println("Buzz");
} else {
System.out.println(x);
}
x++;
recursive();
}
}
}

5. What is open source software? What is so good about it?
Open source software is source code that is viewable to the public and is open for the public
use. The public can use, change, and improve the software, and redistribute it. What is
so good about it is that any one can help improve the code because the code is viewable.

6. In a forum, does a subject "HELP!!!!!" give you any insight of what that person needs? Is this a proper subject line? What should be a proper subject line?
No. No. A proper subject line should describe something fully and precisely on what you
need help on.

7. Why would you test your own code? What are three types of testing?
You should test your code to see that your code is doing what you want it to do. Acceptance,
behavioral, and unit.

8. What is so good about ANT? What are some things that ANT does?
ANT is a java-based build tool that checks your project and says if your project is ready to
be distributed. Some things is that it checks your source code, byte code, and runs
tests.

9. Why should you comment your code? Is updating your comments important? Why?
You should comment your code to state what is going on in certain areas of the code, what
the program is about, and why it is doing what it is doing. Yes, it is important because
if you do not update your code then whoever is looking at your code is trying to figure
what is going on, they will read that comment, and that comment and the code will not
match each other.

10. What is subversion and why is it helpful.
Subversion is a free open source version control system. It is helpful because it manages
files and directories and the changes made to them. The owner can keep track of what
has changed, and backup to older versions of the code if they want to.

Wednesday, October 14, 2009

Project Management and SVN

Working with Google's Project Management and SVN has shown me two programs that are very useful. SVN or subversion, is a useful tool that a group could use when working on a big project. It allows the group of people to make small or big changes to the projects and commit the changes to the source server for everyone in the group to update. SVN differs on different machines, so what I used was TortoiseSVN, MAC uses smartSVN. What is really great about SVN is that it always checks for the most recent version, so if you were to try and commit the code you fixed and someone else has done so before you, you have to update according to their fix before you can commit yours. This feature gets rid of update problems.

By learning so many things about programming, it has shown me lots of resources. I did not know Google had so many features. Google Project Management has made it easy to load all my project files on to one server, and anyone can access it and make comments. Which is really great because the more input from people the better my project will be.

To go to my discussion page click here

To go to my project page click here

Thursday, October 8, 2009

JUnit: Robocode Testing ... not a Crew

JUnit testing is code that is programmed to test a programmers main code to see that the code that they wrote is doing what it is suppose to be doing, or it could be used to see statistics in the code so that the programmer can make the program better.

When we first started using JUnit, I noticed that not just me but everyone was having a hard time just trying to write code to test our main java file. I thought it was a little funny but it is pretty hard. However, now that I know how to do it and how it works I think I can make more JUnit cases for future programs.

What I tested in my robocode program is if my robot can beat two sample robots, if it turns to try and ram another robot if another robot is close, fire power, if my robot loses all its energy, and if it at least hits another robot when it fires. I believe that all these test cases were hard to make because at first I had no clue on what I was doing. I had to sit and look at classmate's JUnit cases and understand how and what they are doing. And since I took too long I am turning in my assignment late. I could have turned it in on time, but I wanted to understand the code fully instead of just turning it in.

Now that I do understand it, there is no problem making another one. What I could change though is how I made my robot because then writing these test cases would be a whole lot easier. What Emma did for me is run my test cases and show me if they failed or executed. This showed me what needed improvement.

Alright!!! without taking more time and not turning my code in, my robocode could be found here.