sexta-feira, 30 de abril de 2010

Thoughts about Document Oriented Databases - part 2

In the first post I presented some issues that I would like to investigate concerning the Document-Oriented Databases. Now I am going to introduce you with the User Story that I will use as basis for that, so "Sit! Here comes the story!".

Let's imagine a group of geek-nerd-friends, every week day they do something during the night. They have the Halo night, the comic store night, the movie night and so on, a full life. Because of that one of those guys wants to manage the nights, they want to know for each night: the participants, the activities of each one, time of those activites, how much people are involved in each activity and which nice widgets they have to use for those activities.


So let's write our first use story (I will give to the user stories some short name to simplify further references):

PYTHAGORAS: As a nerd, I want to organize the night and distribute the activities of that night across all my nerd friends.
  • All the nights have a name, like Halo night or Comic store night.
  • It always happens in a specific day of the week, like Halo night is always on wednesday.
  • To have a nice night we should execute a group of activities (buy food, bring the game, etc).
  • Each activity has one responsible.
  • Each activity could need the help of 1 or more people.
  • Each activity could require one or more widget to be executed (using the iPhone to find the pizza store, the teleport machine to arrive in time, etc).
  • Each activity should be done to have a nice night.
  • A night is ready to start when all the activities are done.

Based on this user story we can create this base class diagram:


These classes will be improved over the time, but with the current information is what we can create.

To understand the class model, here is the test case of the Night::isNightReady() method, it will help to understand what a Night and an Activity is:


@Test
public void testIsNightReady() {
Night saturdayNightFever = new Night();
saturdayNightFever.setDayOfWeek(DayOfWeek.SATURDAY);
saturdayNightFever.setName("Saturday Night Fever revival night!");

//No activities means that the night is read to start
assertTrue(saturdayNightFever.isNightReady());

//Let's add a list of activities in the night
List<Activity> activitiesOfTheNight = new ArrayList<Activity>();
saturdayNightFever.setActivityList(activitiesOfTheNight);
assertTrue(saturdayNightFever.isNightReady());

//For a saturday night fever we need to practive dance listening the BeeGees K7
Activity practiceDance = new Activity();
practiceDance.setWhatShouldBeDone("Dance listening BeeGees K7");
practiceDance.setResponsible("me");
saturdayNightFever.getActivityList().add(practiceDance);

//And also get the nice white suite
Activity takeTheSuite = new Activity();
takeTheSuite.setWhatShouldBeDone("Take the white suite at mother's house");
takeTheSuite.setResponsible("me");
saturdayNightFever.getActivityList().add(takeTheSuite);

//And finally meet the girl
Activity meetTheGirl = new Activity();
meetTheGirl.setWhatShouldBeDone("Meet the girl at his house");
meetTheGirl.setResponsible("me");
saturdayNightFever.getActivityList().add(meetTheGirl);

//I have done none activity, so the night is not ready to start
assertFalse(saturdayNightFever.isNightReady());

//I've found the K7 and danced a lot, but still not ready.
practiceDance.setDone(true);
assertFalse(saturdayNightFever.isNightReady());

//Got the old father's white suite at moms house
takeTheSuite.setDone(true);
assertFalse(saturdayNightFever.isNightReady());

//Meet the girl
meetTheGirl.setDone(true);

//Now it is time to ROCK
assertTrue(saturdayNightFever.isNightReady());
}


And finally I have set a project at GitHub: TADOD, so I will keep publishing the code there.
It is a maven project, so it should be easy for everyone to download it and run. All the entries in the blog will be present in the project site (just need to execute mvn site).

In the next post I will define the interfaces of the services, so we will be able to create the test cases and later start your analysis.

See you soon, and have a nice 1st of May (beware of the Punks around).

Nenhum comentário: