Tuesday, October 20, 2009

Answers please

1. A foreach or a for/in loop is a new loop that was added in Java 5.0 that executes its body once for each element in an array or collection.
for(declaration : expression)
statement

int[] foo = {1, 2, 3, 4, 5};
for (int i : foo) {
System.out.println
(i);
{







Source: Java in a Nutshell pg 50

2. More stress
Less efficiency
More frustration
More pressure, etc.

Source: http://www.nytimes.com/2008/10/25/business/yourmoney/25shortcuts.html?pagewanted=2

3. If companies use the open source software as their base, their "value added" programs might be considered "derivative works" and would then need to make the source code available even to competitors.

Source: http://www.abanet.org/intelprop/opensource.html

4. High coverage rates means that a lot of code was exercised. It doesn't mean that the code was exercised well.

Source: http://www.ibm.com/developerworks/java/library/j-cq01316/index.html

5.
1)Estimating the time to modify existing code.
developers: To check code quality before attempting to modify it
managers: To get a better estimate of time a developer needs to do the work on that code.
2) Evaluating code quality
Shows where code lacks testing
3) Accessing functional testing
Use results to help facilitate risk mitigation

source: http://www.ibm.com/developerworks/java/library/j-cq01316/index.html

6. GNU = GNU's Not Unix
If the GPL software is modified, it must be distributed under GPL. The GPL spreads to any modified GPL software.

7. Source available software has the source available to be viewed but it cannot be modified or redistributed like open source software.

Source: http://en.wikipedia.org/wiki/Open_source_software

8. Identity-based: Two references are equal only if they refer to the same object.
State-based: Two objects are equal only if they contain the same value.

9. List

10.

<target name="init">
<
mkdir dir="build/classes" />
</
target>





Source: "Ant in Action: Java Development with Ant"

Sunday, October 18, 2009

Buddy better study

There is a midterm coming up in my software engineering class so I am posting up some review questions. See how many you can answer without using google.

1. Describe what a foreach loop does and give an example of a foreach loop.

2. List 3 consequences of multitasking.

3. Describe the concern companies have with using open source software in regards to derivative works and intellectual property rights.

4. How are coverage reports often misused?

5. What are the 3 best practices for using coverage reports according to "In pursuit of code quality: Don't be fooled by the coverage report"?

6. What does the acronym GNU stand for and what does it mean when it is said that the GNU General Public License is viral?

7. What is the difference between open source and source-available?

8. Describe the two approaches to defining equality and hash value according to "Java Theory and Practice: Hashing it out".

9. Which collection is most appropriate for a list of strings in alphabetical order with duplicates.

10. Write an ant target called "init" that creates an output directory for generated files called "build/classes".

Answers:
1. A foreach or a for/in loop is a new loop that was added in Java 5.0 that executes its body once for each element in an array or collection.
for(declaration : expression)
statement

int[] foo = {1, 2, 3, 4, 5};
for (int i : foo) {
System.out.println
(i);
{







Source: Java in a Nutshell pg 50

2. More stress
Less efficiency
More frustration
More pressure, etc.

Source: http://www.nytimes.com/2008/10/25/business/yourmoney/25shortcuts.html?pagewanted=2

3. If companies use the open source software as their base, their "value added" programs might be considered "derivative works" and would then need to make the source code available even to competitors.

Source: http://www.abanet.org/intelprop/opensource.html

4. High coverage rates means that a lot of code was exercised. It doesn't mean that the code was exercised well.

Source: http://www.ibm.com/developerworks/java/library/j-cq01316/index.html

5.
1)Estimating the time to modify existing code.
developers: To check code quality before attempting to modify it
managers: To get a better estimate of time a developer needs to do the work on that code.
2) Evaluating code quality
Shows where code lacks testing
3) Accessing functional testing
Use results to help facilitate risk mitigation

source: http://www.ibm.com/developerworks/java/library/j-cq01316/index.html

6. GNU = GNU's Not Unix
If the GPL software is modified, it must be distributed under GPL. The GPL spreads to any modified GPL software.

7. Source available software has the source available to be viewed but it cannot be modified or redistributed like open source software.

Source: http://en.wikipedia.org/wiki/Open_source_software

8. Identity-based: Two references are equal only if they refer to the same object.
State-based: Two objects are equal only if they contain the same value.

9. List

10.

<target name="init">
<
mkdir dir="build/classes" />
</
target>





Source: "Ant in Action: Java Development with Ant"

Wednesday, October 14, 2009

A good host offers you food from their own fridge: Robocode Hosting



Robocode Google Project Hosting: robocode-kks-counterall
Discussion Group: robocode-kks-counterall-discuss

As I continue working on my Robocode project from my previous posts I have encountered a problem. Peers are one of your best sources for help and improvement on a project. However, reviewing someone elses code that is constantly being changed can be a hassle. I have had times when I download a project from my peer's blog I am unable to run it and have to wait for them to fix whatever they need to fix and upload the file back to their blog.

The use of google project hosting and svn helped alleviate that problem. If I want to take a look at someone elses project and make some changes that I think will improve the robot I can checkout the project, make the changes, and commit those changes.

I used TortoiseSVN which was a little confusing at first because there is no main application that starts up, and instead runs from Windows explorer. I also had some problems with adding codesite-noreply@google.com as a discussion list member in my robocode-kks-counterall-discuss group. I still am unsure about how it works.

Wednesday, October 7, 2009

Robocode: Test, test, test


Download: CounterAll + jUnit tests
Improving on my previous robot CounterAll from my previous posts I added 6 new jUnit tests. There are 3 different types of tests: acceptance tests, behavioral tests, and unit tests.

The acceptance tests were the easiest to create because all they tested was whether or not my robot beat another robot. On the other hand, I think behavioral tests were the hardest because most of the time they required the use of other methods and classes from within robocode such as the BattlefieldSpecification class. I also had to refactor my code for my unit test which calculates the power the robot shoots at.
Although it was a pain to change my code in order to better test it, I think it improved my code and helped it follow the rule of having small simple methods.

Although I did create these tests it doesn't mean that my robot is completely of good quality. I did try to write tests that ensured the robot accomplished the behaviors it was intended to do. However, that doesn't mean it will beat every robot. Also if I did not provide varying and a thorough amount of parameters to test for, the test itself wouldn't ensure accuracy.
I also ran Emma to view a coverage report of my tests. I was surprised to see how low the coverage was for the class percentage, only 67%. The method, line, and block coverage were more reassuring with above 80%.