Mostrando postagens com marcador development. Mostrar todas as postagens
Mostrando postagens com marcador development. Mostrar todas as postagens

segunda-feira, 13 de setembro de 2010

And the week begins...

Today is Monday, so instead of talking about any issue, I would prefer to come back the series of "Nooooo it cannot be true, I haven't read it!".

Software Illusion

Code talks


Well, what can I say?


Enjoy the week ;-)

The music is not related to the post, but I was listening to it yesterday so here it goes Long Before Rock 'N' Roll, from Mando Diao.

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!

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!

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).

segunda-feira, 29 de março de 2010

New IDE concept. Finally something new!

Last Saturday I was having breakfast with IT posts and I found this really interesting post Code bubbles. Ide Revolution.

The post is an interview with the guy that is working on this IDE concept as a thesis. The interview is a little bit long so if you want to go directly to the point and see what it is about take a look in the video available in the project overview page, or for those unable to see the video here is the details page with some images and explanation.

Hope you enjoy it. New ideas for the new week!

sexta-feira, 26 de março de 2010

Jazz

Today I am going to move from the usual coding subjects to something more related to process. I guess that the Rational suite is well know for most of us, together with the Rational suite there is the Unified Process concept (in a creational point of view: first the man created the Unified Process, he looked and it was not that good, then he created the RUP and it was ok, but the desire for more make him create the Rational suite – and now he is ashamed for the rest of his life).

I am not here to discuss the quality of the Rational Suite (which I am not a fan) or the Unified Process (which I am sure is misunderstand process), but I want to bring to you a new initiative from IBM the Jazz.

According to the IBM Jazz website, this initiative could be define as: "…Jazz is an initiative to transform software delivery by making it more collaborative, productive and transparent, through integration of information and tasks across the phases of the software lifecycle".

Jazz is a set of concepts and, of course, a group of IBM products; you can think about those products as an evolution of some Rational products. But in this case I guess with some major differences (in the direction of the Sun): it has an open source architecture, which means that you can plug any external software to work with it (open ground to open source software) and it has a community portal. The portal has a lot of information, so you do not get stuck with some guru-guys saying what should be done and what not, no more high cost guys or information blockage. I am not saying that everything is for free, but the community can grow by itself.

A nice set of products, the community process is not new, but is always good to see people getting into it, mainly in the area of process where the community idea is not really easy to accept. But the most important part, in my humble point of view, is the move to some agile process. You absolutely do not see anything in the Jazz.net saying about Scrum, Agile, and so on, that is absolutely true – what is ok because it is just products and you can use it with the process that you like most.

If you watch the videos in the portal you will notice what I am talking about. For example this video: the Collaborative ALM Demo – The Jazz Revolution tells a nice story that has a happy end because of the Jazz. But is it true? I don't think so; I have counted 2 times the agile word, 2 times continuum integration and 14 times the Iteration word, plus N points in this iteration and so on. If it is not something similar to Scrum I don't know what it is.

The point here is: nice tools help but do not solve our problems and the same time that short iterations, real scope review, communication, real information that serves as input for the work, test cases and other stuffs that makes the big wheel turn helps much more.

In a more philosophical way of thinking: a beautiful ring (the tool) is still just a ring without a gentle hand (the process) to have it, and I can imagine much more uses for a gentle hand than to a ring.

sexta-feira, 19 de março de 2010

Initial Experience

Yesterday we "finally" deployed in production a version of the software that took quite a long time to go. And thinking about it come to my mind a article that I read in IBM portal talking about Initial Experience.

When we find ourselves developing software for "internal" costumers is quite easy to forget that your software could cause a good/bad impression at the user, mainly if it is a brand new software, or those long time expected releases. The common thought is: why should we botter about it when the costumer has just one option: accept it or accept it; but thinking in this way doesn't make your product better I can insure you.

A serie of articles from IBM bring some ideas about this Inital experience of the users with the software. The initial experience is just a relation between the user expectation with the product and what he really get from it.

For sure it is not a simple matter, because we have differente level of users, uses of them in the product and so on, for example: is this user a novice or an expert?
Which are the factors that we should consider in this inital experience? And so on.

So take a look in the articles, read about it and next time that you are going to make a deploy of something new, think about it. It could be the difference between a easy life in the following weeks or the opening of the hell's gates.

IBM Design: Inital experience

And remember: the first kiss is that really matters ;-) Nice weekend.

segunda-feira, 8 de março de 2010

Thoughts about Document Oriented Databases

These last two weeks I have read many articles about Document-Oriented databases, for sure they have potential and also it is true that it is not the panacea to all our problems.

After so many readings I started to think about some scenarios were this kind of databases could be applied in a efficient way. Efficient way is a too generic definition, so before highlighting the scenario I would like to clarify the elements that I would like to investigate.

I want to divide it in two parts: developing and performance. In the developing area I want to find out:
  1. The effort to create the access layer;
  2. Due the document/object changes across the time, how much is the effort to migrate the data? Is it necessary to migrate the data or can we have a base with different documents version?

In the performance area I want to find out:
  1. How much time is spent in a single insert?
  2. How much time is spent in a single update?
  3. How many concurrency inserts can I have?
  4. How many concurrency updates can I have?
  5. How fast is a list query of the documents ?
  6. How fast is a list query of the documents during a sequence of inserts?
  7. How fast is a list query of the documents during a sequence of updates?
  8. Execute all those performance tests in a single node DB and a multi node DB.

With this analisys I would expect to have a better understanding of the Document-Oriented model, in development area and in the application runtime.

Ok. Now is time to define the scenario that I would like to evaluate this parameters. Let's suppose that you have an application that is a workflow based in a document.
This document is a set of information offered to your user/client, and as expected this document has a structure (as complex as your business). Let's ignore the workflow part and stick in the document.
  • We need to have the basic 4 operations for the document: create, read, update and delete (CRUD), plus a view of the list of the documents (with a small set of the data);
  • All the CRUD operation is executed at the document level and not at parts of the document;
  • The whole application uses the this base API, so every update/insert is make in the complete document.
  • It is done like this to simplify the API and due the fact the user interface to insert/update the information is build at runtime (I can have everything or just few fields).
Well this is the base scenario that I would like to investigate, it is because in my point of view the Document-Oriented database would fit here much better than the standard relational database.

In the next post I will step into the document definition and the user stories that I would like to implement in order to start the investigation.

See you soon.

sexta-feira, 5 de março de 2010

Opinion about NoSQL coming from a DB guy

This week I didn't have much time to write a nice blog, some ideas but nothing concrete. As usual on Friday I am trying to post something more light, so today I am going to post a presentation of Brian Aker about the NoSQL trend.
It is a 7 minutes video with some jokes about this idea.



Enjoy it :-)

segunda-feira, 1 de março de 2010

When the code talk to you...

People say that we can find the answer for our question in the smallest thing of the life, that could be true, but what should we do when instead of answer we find questions? And when those questions are in the code that you are working with? What should we do?

From time to time I find some questions in the comments of the code, I always look at it wondering if someone will ever answer them, or even if I answer it then someone will read it? Will I get another question? Will the code chat with me?

As I don't pretend to have all the answer of the world I am posting some questions here, so you all could help me with this important task: answer questions posted in code comments!









And remember: don't let your code without answer, so if you find any question flying around, please answer it or send it to me. I will post it here and then we can answer all those questions, once the question about the life, universe and everything else is already answered (and everyone knows that it is 42).

Have a nice week.

sexta-feira, 26 de fevereiro de 2010

Development, music and the 80s

Today is Friday! It is usually a day for going out drinking something, listening some music, having some fun.
It is difficult to find someone that doesn't like this kind of thing, isn't it? I usually develop listening to music, tying to have some fun too (all of this just to say that I listen to music).

Yesterday was thinking about what to write today in the blog, a lot of nice topics end up in my mind, but in the between a match and the other in the Winter Olympic Games I zapped to a channel with a 80's marathon. Everyone that remember the 80's movies knows that they have a lot of music, kind of ridiculous clothes and a lot of teenagers.
But listening to them I notice a lot of similarities with your developer day life, I don't know if it is because the personal computer are a boom from the 80's too or just a trick of the destiny, but it is unbelievable how those music says about your job.

Here I will add parts of some lyrics and you will see (ok not all of them are from the 80s, but come on everything has a beginning)

Customer asking for a new project
I need a hero

He’s gotta be strong
And he’s gotta be fresh from the fight

He’s gotta be sure
And it’s gotta be soon
And he’s gotta be larger than life

Somewhere after midnight

- I need a hero "Bonnie Tyler"



About that last minute change request

Who's gonna tell you when,
It's too late,

You can't go on, thinkin',
Nothings' wrong, but bye

- Driver "The cars"
A ever standing request in the list?
Its my own design
...
I can't stand this indecision
Married with a lack of vision
- Everybody Wants to Rule the World "Tears for fears"
A new incredible "never-ever-though" feature rises
What is it good for
Absolutely nothing
Say it again
...
What is it good for
Absolutely nothing
- War "Edwin Starr"
A good UI interface
More than just blind ambition
More than just simple greed
More than just a finish line
...
Like a streak of lightning
That flashes and fades
...
More than high performance
More than just a spark
More than just the bottom line
...
- Marathon "Rush"
Trying to avoid that 90 degrees change on the project
But it's gonna take money
A whole lotta spending money
Its gonne take plenty of money
To do it right child

Its gonna take time
A whole lot of precious time
Its gonna take patience and time, ummm
To do it, to do it, to do it, to do it, to do it,
To do it right child
...
- Got my mind set on you "George Harrison"


Fell free to send me any nice music that you think represents oour day life. I will try to make this post more often!

Enjoy the day! Enjoy the life!

terça-feira, 27 de outubro de 2009

Someone stoled my session, "And now who can defend me?"

I know that it is not nice to keep talking about Sessions, there so nice subjects out there (modularity, agile, full stack systems, etc), but they seems so far away from me that I cannot really avoid talking about Sessions.

Yesterday I recorded the problem with memory leak, which somehow is related to the HttpSessions. I believe that using a tool like a Session (which is for sure important) make us lazy.

When the system is slow, just put things on the session and everybody will be happy, but is it true? Absolutely not! Some day someone will come to your desk with a nice chart saying saying that your wonderfull application is consuming so much memory that they need to restart the server every two days.

And then what are you going to do? Once everything is binded to the session, your live will get difficult doesn't it? Well, before getting into a new project or storing your nice new object into the session take a look at subjects like REST or some frameworks like Play that avoid the use of session.
For example the framework Restlet do not supply you with any access to the session, and the Play "session" is a simple Cookie, which for sure is small enough to avoid any massive storage there.

Today I am little bit lazy, so here is a list of sites discussing it across the web (there are no state of the art, but you are all grown and can extract the best from it!):
I hope it could make we all think a little bit about it.

segunda-feira, 26 de outubro de 2009

Oh my God, I don't understand why I cannot use static maps to store user information.

Sorry folks, it was a long time since the last post, but I promisse that I am going back to stay.

Today we will take about a issue that I have heard about in the office for the whole last week: memory leak.

I believe that some memory leak is ok to happen, mainly if you store things on the HttpSession. Let's be realistics, it is a easy solution and if the data keeps on the memory for 30 minutes who cares?

But actually the memory leak that we have found is not realted to the session, it was related to the 2 different issues: thread variables and static maps.
  • Thread variables: a lot of things were being stored into the thread variable, and using as key some object. First, usually the web servers reuse the threads, so the information there was being keep for a looong time. Second object as key SHOULD-ALWAYS-NO EXCUSE TO NOT HAVE hash, otherwise baby, guess what? Every add is a new entry on the map. That's a bingo: memory leak.
  • Static maps: this is just a more obvious leak than the thread variables, use a static map to store information, where the key also do not implement a proper comparation methods. So every entry lead to a forever-and-ever information into the memory. As as Murphy says: there is always something worst, those information stored into the map where GUI objects, which was reference even to God. And the leak could lead to a OutOfMemory after 5 screen hits.

Nice ins't it? I can understand the problems, what I cannot understand is people blaming the GUI obejcts to have the necessary references. Come on, they are GUI objects that are supposed to work for a single request.
But the real problem is that people still tries to solve problems that are not present yet. The performance problems are the classical example: you never run the application, so you don't know if there is performance problems or not. Why should you address them? Why to worry about it?
Most of the problems could be solve with a proper approach to the problem and not with cache (that usually leads to a whole bunch of other problems). And if the cache is need think about what are you doing: my key if unique? is it replacing the information? what is the live time of the data? should I need another cache than the HttpSession? ...

Make like the buddhists: breath 10 times before doing something, if after that time you still want to do it, go and think about it and then do it, otherwise just go home and relax.

sábado, 21 de março de 2009

Alice's Adventures in Procedureland!

When Lewis Carroll wrote his book there weren’t stored procedures, otherwise for sure it would appear in the book. Most of the time procedures seems to come from a dream land, result of a big nightmare.

Well sometimes we have good dreams, as sometimes we have good procedures, but most of the time it is just a dream or even worst: a nightmare.

Let’s put like this: even water could kill in a excessive amount, imagine procedures. That is what I am facing in the current project, a land with a lot of procedures: some of them are like the Cheshire Cat others like the Queen of Hearts, but for sure they are not from our world.

Why are they not from here? You my asked me: well can you version stored procedures? Can you unit test or debug stored procedures? Is there a coding pattern? Can you use common development concepts, fair simple ones like: functions, code split, reuse? Probably the answer to most of these question is: sorry you cannot do it!

Ok folks, before you start blaming me about performance issues: I agree, there is a right place to everyone, even to the stored procedures. But before the end let’s take a look to some code around my project, look how the dependency to the stored procedure recreates some filthy ORCS:



create procedure PP_TODAY
as
begin
select today=convert(char(10),getdate(),103)
end



create procedure PP_HOUR
as
begin
select hour=convert(varchar,getdate(),103) + " " + convert(varchar,getdate(),108)
end


How can we afford this? And do you know what: these procedures are used as part of other procedures in a batch mode. Yes that is true: batch! The files are read and stored in temporary tables and after that a procedure reads each line and them split it, put it into another table and them make a huge processing stack. Let’s face it: we are expending time and resource from the database machine to process something that could be done in another place, look it is even worst: we probably will be running against some production code, slowing down our user and requiring a more and more powerful machine (and at the end blaming the DBMS that we use).



Now I will ask you: is it right? Is it something that Alice would do in the wonderland?

terça-feira, 16 de dezembro de 2008

Ruby scripts

Hello all!

As I have promissed I will post here some Ruby scripts, nothing really amazing but I thing that it could be a nice startup for Ruby studing and it could be useful for someone.

The purpose of the script is to generate random files, with fixed record size (like those used by COBOL programs). The zip has three files:
  • FileCreator.rb: the program itself, it is responsible to create the file, you script should refer to it;
  • TestFileCreator.rb: the test case, we never forget about it; and
  • CreateFile.rb: an example of how to use the program, it is the script itself, if you want to run something start with this.
You can download it here.

I hope it could help you somehow.

See you soon!

sábado, 13 de dezembro de 2008

Rails 2.0 and scaffolding

One of the most interesting Rails tool is the scaffolding, but when you look aroung the internet you notice that almost all the tutorials refers to the Rail 1.x.
Unfortunetly there were a lot of changes in this tool. Sean Lynch wrote this nice tutorial about version 2.0: Rails 2.0 and Scaffolding Step by Step.

sexta-feira, 12 de dezembro de 2008

Ruby roadmap

I am new at Ruby development and I AM not sure that it could solve the Global Warning problems, but it could be a nice to tool to have in your pocket.

For example, yesterday I needed to extract some data from a bulk of files, so I created a one shoot script that help me a lot.

 

I will not post here the script that I created, it will not help anyone but I will write down a Ruby roadmap, if you are a beginner it could help. First of all we need to understand that Ruby is just a language, it is not related to web stuffs or things like that; but now you come as say: “But my little friend said that Ruby is a boost for web application, you are a liar, your… your.. fool!”

Take easy little boy, I will explain it  to you: the magical word for web is Ruby on Rails. But what is it? Rails is the underline framework for Ruby that makes web development easier, because of the conventions that it is based on.

 

First step you should go to the  website: Ruby on Rails, go directly to the Get Started. There you will be able to download the Ruby and get the instructions to install the Rails, I recommend that you install both (it doesn’t matter if you are going to do scripts or web development).

Once you get your environment running make the first application (suggested at the Get Started), after that you should make a difficult decision: learn the language or keep running in a nice tutorial. I am for make a nice tutorial, but I will let you choose:

·         Learn language: This is the most crazy book for programming language that I have seen so far, but it worth a look: why's (poignant) guide to Ruby. It will give you a nice overview of the Ruby language, there isn’t any web reference here.

·         Tutorial: there is plenty tutorials about Ruby on Rails in the internet, but I suggest these: Getting Started With Rails, Tutorial Step One (wiki). The last one is more direct, although the text is a little bit confusing.

I think that it is a little bit amount of data to start with Ruby. Just move yourself little boy and start learning it, next I am going to post a Ruby script to create fixed file size for testing.

domingo, 12 de outubro de 2008

Testing your equals methods

We all know that testing is something important. But there is some situations that writing a test code could be quite confusing.
One of this situations is how to test a equals method and ensure that all the attributes are tested correctly. Most of the time we just test if all the fields are equals or not.
It is ok, but it is far from being complete and usefull.

Here is a pattern that you can follow and it will insure that all the fields are being tested correctly:

  1. Create two values for each of your class attribute, with different values between them;
  2. Create two objects, instances of the class that you want to test, call one as base and the other as ref;
  3. Make this block of code for each attribute (it doesn't matter the sequence):
    base.setAttribute(ATTRIBUTE);
    ref.setAttribute(DIF_ATTRIBUTE);
    assert !base.equals(ref);
    ref.setAttribute(ATTRIBUTE);
    assert base.equals(ref);

Making things like this will insure that your test code for equals works perfect. Let's say that it is a little bit painful to make it for a big class, but of course you could automate it.

terça-feira, 10 de junho de 2008

Lightweight development environment

Yesterday my deskptop crashed again (ok, it is not a unusual thing to happen), and now I am stuck with a old notebook (P233MMX with 64MB and Windows ME).
I know that I cannot expect something really amazing from it, but we do not have a lightweight development environment. In that notebook I cannot expect something more complex than a notepad.
It is obvious that I will not be able to use something complex like Eclipse IDE, but most of time we do not need something like that. How much time do you spend waiting for plugin loading, or any other nice stuff that you never use.
I tried some light source code editor, but nothing really amazing, what you normally get from then is a code highlight. In my opinion what we need in these kind of situation, and in almost all the other situations, is something simple that can integrate easially with external tools (that will make the dirt work when you need it).
Let's agree that features like code refactoring, code highlight, online error report, auto compilation, etc are nice and really usefull, but we get to much used to it. Beliave me that it is difficult to work in a simple source code editor, sometimes it is important to come back to something simpler and recicle our base knowledge.
Remember: without a good base we cannot make a building that reach the sky.
For me as a homework: try to find tools for a lightweight development environment (advogates of JEdit, VI, Emacs, etc can post comments about their advantages).