Tuesday, June 30, 2009

PMP Exam

Passed my PMP exam today finally - what a ride it was.

It was tough, the real exam questions were very different from the mock exams I had been preparing with, in terms of the style, definitions used etc. There were a few new terms as well, that I never read of before.

Luckily the time was more than enough. I was able to run through all the 200 questions in 2 hours, 30 mins. For some of the questions I did take a lot of time to think as well. At the end I had around 25 questions marked for review and 4 not answered. The next 90 mins were enough to review and complete them all. I still had 23 mins remaining before I clicked "End Exam".

After I clicked "End Exam" I was asked for an optional survey. I wanted to fill the survey in good faith but who wants to wait 10 more mins to see a pass / fail score? They should have asked for the survey after showing the score.

Anyways, after the exam we went and watched a movie and had nice dinner at Chipotle. End of a saga and begining of a new one - whats next?

I want to take a bit of a break and then go for Sun Certified Java Web Services Developer or Sun Certified Enterprise Architect. Not sure yet which one to pick. And of course not to forget - keep an eye on those PDU's needed to keep PMP credential.

Caio

Thursday, June 11, 2009

No getters and setters

To design good software working with Domain language and making it part of Object's is very important. One way to get this, I think is to get away from the "get" and "set" polluted code.

consider this code:

public class Person {
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private String name;
}

We would end up using this code in its simplest form like this:
Person theOne = new Person();
theOne.setName("Neo Anderson");
System.out.println(theOne.getName());

Instead we can easily modify this code to make it more "domain driven"
public class Person {
public String name() {
return name;
}
public void nameIs(String name) {
this.name = name;
}
private String name;
}

Our new code would be:
Person theOne = new Person();
theOne.nameIs("Neo Anderson");
System.out.println(theOne.name());

you can tell this is more english like code as well. You can easily read line 2 in the code there as "The one's name is Neo Anderson". You can easily read line 3 as "Print the one's name"

I believe in this approach. The easiest way implement this approach is:
1. If you have a private variable names "varName", your getter method would be named "varName"
2. The setter method would be named "varNameIs" .... append with an Is

Wednesday, June 10, 2009

Eclipse: Run a single unit test method

In eclipse if we have a junit test class with several methods in it we can run a single method test. Select the method name, right click and run as junit test. The setup and teardown are run well also.

This technique, however, does not work with testng tests. Eclipse will run all the test methods.

Tuesday, June 9, 2009

TestNG and EasyMock

Unit Testing is pretty cool once you get a hang of it and have the right tools to play with it. I started using TestNG and EasyMock recently. TestNG has this neat feature that allows us to partition the tests as unit, integration etc. EasyMock is not as easy but not bad.

Some problems I faced with unit testing were that sometimes a single unit test would run fine when they run from eclipse, but when the suite is run on CI they would fail. Most of the times the problem was that a easymock object was created and reused in its stale state