Value is always contextual

A while ago, I met a team that was developing a classic enterprise system using a JEE-based stack. A particularity of the system was that the server side was organized in 5 layers, even if 2 or 3 would have been enough.

This decision had visible effects in the code and raised several problems. One of these was the proliferation of data transfer objects. To keep the layers separated, the team opted for every lower layer to define its own data transfer objects to be used for the communication with the upper one. This meant that for every entity they wanted to transmit from the lowest to the topmost layer, they had to make of use multiple data objects.

I actually stumbled across this issue very soon after I started to analyze the system. With this occasion, I noticed that there are multiple classes called in the same way, such as XxxDTO (the convention was to name all data transfer objects as DTO), where Xxx usually denoted a domain concept. These classes were highly duplicated, the main difference being that they belonged in different packages. Due to this situation, from an external point of view, I saw an important code quality problem.

Of course, I proudly raised this issue for debate. The issue raised sparks of hope in some of the team members' eyes. Yet, there was no debate. I was quickly told that this discussion already took place a long time ago, and the decision was to keep the 5 layers. There were several reasons I did not agree with including the premature generalization of behavior in the vague possibility of reusing the lower level layers in other contexts. And so did other team members. But, the team as a whole took the decision already. From the stories that circulated around, it became clear that the debate did make all the pros and cons explicit, and the decision was taken in full awareness.

Given the situation, there was no point raising the issue again. And, there was no point in continuing detecting the issue either. In fact, the opposite was more appropriate. Because the team already decided on what is important, instead of seeing the issue as a bad thing, I put in place a detection that helped the team maintain this decision. In other words, we considered a problem if an entity did not have multiple DTOs in several packages.

The actual detection was basically the same from an algorithm point of view. Only it guarded a completely different value.

Value is always contextual. And the associated detection must be contextual, too.

Posted by Tudor Girba at 18 August 2011, 8:53 am with tags story, assessment link
|