segunda-feira, 31 de maio de 2010

Agile development and how people are using it.

Are you interested in Agile Development? There a quite interesting Scott Ambler webcast that you could be worth listening to it.
This webcast is a IBM presentation, so you could expect some IBM view and products for Agile, but at the same time it is based in a survey distributed across many organizations, so you also could expect some real information (like what happens when the teams are distributed and not collocated as the initial ideas, agile only works for small teams and so on).

Any way as Scott say in the webcast, there isn't any new in Agile Development compared with other kind of developments. So don't expect magic words to make everything start working from day to night, but I recommend you to spend some time listening to it and put some extra color in the big picture of Agile Development.

Here is the link to the webcast: Busting the Myths of Agile Development: What People Are Really Doing.

Have a nice week!

quinta-feira, 20 de maio de 2010

segunda-feira, 17 de maio de 2010

Thoughts about Document Oriented Databases - part 3

In the last post I presented the first Use Story and the base classes for the problem, now I will walk into the service layer.

Let's make our example a little bit more complete with others user stories:
NEWTON: As a nerd, I want to be cool having the possibility to have a specific night for a specific day.
I can have a night for a specific day that differs from the normal night for that day of the week. It is a special night occasion.
PASCAL: As a friend of a nerd, I want to know when a night happens.
Based on the name of the night I want to know when it happens.
Based on the day of the week I want to know what is the night of that day <(I don't want to avoid those nerd guys)>.
I want to know which night of a specific day.

We have based your class diagram on the PYTHAGORAS use story, now with the addition of the NEWTON and PASCAL user stories we have enought information to create our first service interface (based on the Night) and your test case for the further service implementations.

So your first service will look like this:

public interface NightService {

/**
* Add a new night to the store. If the night is supplied with an ID it will be replaced.
* After the call to the registerNight method the Night object will have the ID filled.
* @param night night to be added.
*/
public void registerNight(Night night);

/**
* Replace the night stored. The provided night should have the id filled in order
* to have the date replaced correct.
* @param night night to be replaced.
*/
public void changeNight(Night night);

/**
* Returns the night by its unique identifier
* @param nightId identifier of the night.
* @return
* Night object, null if there isn't any night for that id.
*/
public Night findById(String nightId);

/**
* Returns the list of nights of the specified day of week.
*

    *
  1. The order returned by the find week day should be from the first include to the last one.

  2. *

* @param dayOfWeek
* @return null when there isn't any night for the specified day of week, otherwise a list with the nights.
*/
public List<Night> findWeekDayNights(DayOfWeek dayOfWeek);

/**
* Returns the list of nights of the specified name, the name match is not case sensitive.
*

    *
  1. The order returned should be from the first include to the last one.

  2. *

* @param dayOfWeek
* @return null when there isn't any night for the specified name, otherwise a list with the nights.
*/
public List<Night> findNightWithName(String nightName);

/**
* Returns the corresponding night for a specific day.
* @param date date of the night
* @return
* Night corresponding to the date, if there isn't any night for that day then returns null.
*/
public Night nightOf(Date date);
}


Based on this service let's created a test case to test all your service implementations. This test case is to make sure that all the services methods are working properly, after that we will be able to start executing your desired tests.


public class NightServiceTest {

private NightService nightService = null;
private TestUtils testUtils = null;

//... Code removed for simplicity

@Test
public void testRegisterNight() {
Night movieNight = testUtils.createNight(DayOfWeek.MONDAY, "MOVIE_NIGHT");
nightService.registerNight(movieNight);
Night movieNightRead = nightService.findById(movieNight.getId());

assertEquals(movieNight, movieNightRead);
}

@Test
public void testChangeNight() {
Night gameNight = testUtils.createNight(DayOfWeek.TUESDAY, "GAME_NIGHT");
nightService.registerNight(gameNight);

gameNight.setName("Man this is the really the GAME night");
nightService.changeNight(gameNight);

Night gameNightRead = nightService.findById(gameNight.getId());

assertEquals(gameNight, gameNightRead);
}

@Test
public void testFindNightById() {
Night wOwNight = testUtils.createNight(DayOfWeek.WEDNESDAY, "WOW_NIGHT");
nightService.registerNight(wOwNight);

String validId = wOwNight.getId();
String invalidId = "invalidId";

Night validNight = nightService.findById(validId);
assertNotNull(validNight);
assertEquals(validId, validNight.getId());

Night invalidNight = nightService.findById(invalidId);
assertNull(invalidNight);
}

@Test
public void testFindWeekDayNights() {
//Create the nights
Night bownlingNight = testUtils.createNight(DayOfWeek.FRIDAY, "BOWNLING NIGHT");
Night arcadeNight = testUtils.createNight(DayOfWeek.FRIDAY, "ARCADE NIGHT");
Night kartNight = testUtils.createNight(DayOfWeek.FRIDAY, "KART NIGHT");
Night pizzaNight = testUtils.createNight(DayOfWeek.THURSDAY, "PIZZA NIGHT");

nightService.registerNight(bownlingNight);
nightService.registerNight(arcadeNight);
nightService.registerNight(kartNight);
nightService.registerNight(pizzaNight);


List<Night> mondayNights = nightService.findWeekDayNights(DayOfWeek.MONDAY);
List<Night> tuesdayNights = nightService.findWeekDayNights(DayOfWeek.TUESDAY);
List<Night> wednesdayNights = nightService.findWeekDayNights(DayOfWeek.WEDNESDAY);
List<Night> thursdayNights = nightService.findWeekDayNights(DayOfWeek.THURSDAY);
List<Night> fridayNights = nightService.findWeekDayNights(DayOfWeek.FRIDAY);
List<Night> saturdayNights = nightService.findWeekDayNights(DayOfWeek.SATURDAY);
List<Night> sundayNights = nightService.findWeekDayNights(DayOfWeek.SUNDAY);

assertNull(mondayNights);
assertNull(tuesdayNights);
assertNull(wednesdayNights);
assertNotNull(thursdayNights);
assertNotNull(fridayNights);
assertNull(saturdayNights);
assertNull(sundayNights);

assertEquals(thursdayNights.size(), 1);
assertEquals(fridayNights.size(), 2);

assertEquals(pizzaNight, thursdayNights.get(0));

//The order returned by the find week day should be from the first include to the last one.
assertEquals(bownlingNight, fridayNights.get(0));
assertEquals(arcadeNight, fridayNights.get(1));
assertEquals(kartNight, fridayNights.get(2));
}

@Test
public void testFindNightWithName() {
Night surprise_Surprise_Night = testUtils.createNight(DayOfWeek.MONDAY, "SURPRISE SURPRISE NIGHT");
Night big_Surprise_Night = testUtils.createNight(DayOfWeek.MONDAY, "BIG SURPRISE NIGHT");
Night surprise_surprise_Night = testUtils.createNight(DayOfWeek.MONDAY, "suprise surprise NIGHT");
Night double_Night_one = testUtils.createNight(DayOfWeek.TUESDAY, "DOUBLE NIGHT");
Night double_Night_two = testUtils.createNight(DayOfWeek.TUESDAY, "DOUBLE NIGHT");

nightService.registerNight(surprise_Surprise_Night);
nightService.registerNight(big_Surprise_Night);
nightService.registerNight(surprise_surprise_Night);
nightService.registerNight(double_Night_one);
nightService.registerNight(double_Night_two);

List<Night> nightsRead = nightService.findNightWithName("SURPRISE");
assertNull(nightsRead);

nightsRead = nightService.findNightWithName("SURPRISE NIGHT");
assertNull(nightsRead);

nightsRead = nightService.findNightWithName("SURPRISE SURPRISE");
assertNull(nightsRead);

nightsRead = nightService.findNightWithName("SURPRISE SURPRISE NIGHT");
assertEquals(nightsRead.get(0), surprise_Surprise_Night);
assertFalse(nightsRead.get(0).equals(big_Surprise_Night));
assertFalse(nightsRead.get(0).equals(surprise_surprise_Night));

nightsRead = nightService.findNightWithName("BIG SURPRISE NIGHT");
assertFalse(nightsRead.get(0).equals(surprise_Surprise_Night));
assertEquals(nightsRead.get(0), big_Surprise_Night);
assertFalse(nightsRead.get(0).equals(surprise_surprise_Night));

nightsRead = nightService.findNightWithName("suprise surprise NIGHT");
assertFalse(nightsRead.get(0).equals(surprise_Surprise_Night));
assertFalse(nightsRead.get(0).equals(big_Surprise_Night));
assertEquals(nightsRead.get(0),surprise_surprise_Night);

nightsRead = nightService.findNightWithName("DOUBLE NIGHT");
assertEquals(nightsRead.size(), 2);
assertEquals(nightsRead.get(0), double_Night_one);
assertEquals(nightsRead.get(1), double_Night_two);
}

@Test
public void testNightOf() {
//24.12.2010 is a friday
//29.02.2012 is a wednesday
//15.05.2010 is saturday
//22.05.2010 is saturday
Night gameNight = testUtils.createNight(DayOfWeek.FRIDAY, "GAME NIGHT");
Night thaiFoodNight = testUtils.createNight(DayOfWeek.WEDNESDAY, "THAI FOOD NIGHT");
Night feverNight = testUtils.createNight(DayOfWeek.SATURDAY, "FEVER NIGHT");

nightService.registerNight(gameNight);
nightService.registerNight(thaiFoodNight);
nightService.registerNight(feverNight);

Calendar _15_05_2010 = Calendar.getInstance();
_15_05_2010.set(Calendar.DAY_OF_MONTH, 15);
_15_05_2010.set(Calendar.MONTH, Calendar.MAY);
_15_05_2010.set(Calendar.YEAR, 2010);

Calendar _22_05_2010 = Calendar.getInstance();
_22_05_2010.set(Calendar.DAY_OF_MONTH, 22);
_22_05_2010.set(Calendar.MONTH, Calendar.MAY);
_22_05_2010.set(Calendar.YEAR, 2010);

Calendar _24_12_2010 = Calendar.getInstance();
_24_12_2010.set(Calendar.DAY_OF_MONTH, 24);
_24_12_2010.set(Calendar.MONTH, Calendar.DECEMBER);
_24_12_2010.set(Calendar.YEAR, 2010);

Calendar _29_02_2012 = Calendar.getInstance();
_29_02_2012.set(Calendar.DAY_OF_MONTH, 29);
_29_02_2012.set(Calendar.MONTH, Calendar.FEBRUARY);
_29_02_2012.set(Calendar.YEAR, 2012);

Night night_24_12_2010 = nightService.nightOf(_24_12_2010.getTime());
Night night_29_02_2012 = nightService.nightOf(_29_02_2012.getTime());
Night night_15_05_2010 = nightService.nightOf(_15_05_2010.getTime());
Night night_22_05_2010 = nightService.nightOf(_22_05_2010.getTime());

assertEquals(gameNight, night_24_12_2010);
assertEquals(thaiFoodNight, night_29_02_2012);
assertEquals(feverNight, night_15_05_2010);
assertEquals(feverNight, night_22_05_2010);
}
}


Next we will make our first implementation of this interface, using a relational database.

See you soon!

terça-feira, 11 de maio de 2010

High availability: defining the terms

It is quite common to see a lot of places talking about availability, how to make your website, program, web service, etc, 24x7.

Even here I talked few times about this subject, but what I miss is some papers discussing the meanings of the terms in this area. A kind of a common language that we can talk about, I know that it depends a lot of your environment, company, software and so on. So in this post I would like to put some light in this subject.

Last month IBM release one of their famous Redbooks (I remember a time that an IBM Redbook was a kind of: "OHHHH really do you have one!, but those times are over with the floppy disks): High Availability in WebSphere Messaging Solutions.

No, I am not doing advertisement about the IBM products, it has an excellent part about concepts, so it really worths reading the Chapter1. Introduction to Availability and Chapter2. Application Design for Availability.

There is a lot of concepts and therms definition that will help you a lot, doesn't matter if you are implementing something in your own software, designing an application, for general knowledge. For me it is a must read for developers, architects, software development support team and so on.

Hope you enjoy the tip!