Before I would ask my question, here is the context: I am working on one part of a relatively big software. In its simplest form there are 3 layers of the software lets call them lower layer, middle layer and top layer. I am working on the middle layer. The job of middle layer is very simple, retrieve the information from lower layer and deliver it to the top layer. It also can receives various requests from top layer and perform actions on the lower layer and provide the feedback to the top layer.

The lower layer is a third party component, hence we agreed on a data model that would be common between middle layer and top layer. These two layers communicate over a proprietary inter process communication protocol. The data model is delivered as part of the framework containing the libs for proprietary comm protocol (hence, the headers containing the models use the namespace of the framework and not the middle layer).

My approach: The way I implemented was to directly use the data model throughout the middle layer, though it used the namespace of the comm protocol, as I consider it the data model of middle layer. So, I would directly read the data from the lower layer into the data model, send it through various sub-layers within the middle layer and to the top layer over the comm protocol.

One of my colleagues criticised my approach, arguing that it is the data model of the comm layer and what if the comm layer changes tomorrow or is replaced with another one, I will have to replace every single instance where I used it through out the middle layer. So, he suggested to use an internal data model which would be used to read from the lower layer and send this model to the point where I send the data over the comm layer to the top layer. Before sending the data I should performing the data mapping to the comm layer data type.

I don't believe he is right, as it is the data model of the middle and I had defined it myself. Only because it has to be sent over the comm layer, it is delivered with the framework hence has a namespace of the framework. But, that does not make it the comm layer data type. Moreover, if the comm layer and hence the namespace changes, it wouldn't be a big problem, as I can solve this problem with just a simple define.

So, the question after a very long story: Does it really make sense to perform mappings with the layer itself? How do you look at the situation?

  • if anything is missing above, can you plz ask further questions to fill in the gaps for "depends". Or asked differently, under what circumstances would you perform data mapping within the same layer (of course other than the fact you actually perform certain transformations so that you data model changes within the layer). In my case, I have one end of middle layer that reads the data and the other end that sends it to the top layer. No data transformation takes place between these two end points (neither do we expect it to happen in future). Jul 9, 2018 at 8:21

1 Answer 1


Where your colleague is right: you should be prepared for the potential requirement of having to support a different communication technology. That does not meither mean his proposed solution is the correct one, nor that you must invest a lot of effort for supporting other technologies "just in case".

What you should care for is, the data model inside your comm layer should ideally be agnostic of the communication technology itself. Think about what happens when you need to switch the technology. Can you reuse most of the data model without having to replace every single instance where you used it? Maybe by creating a "comm layer V2", with compatible (or at least almost compatible) data structures?

If you can do this, there is quite no need to add another layer of indirection in form of an additional "internal data model". Otherwise, it might be worth to think about it.

  • I totally agree that my implementation should be as independent as possible from the transport layer. However, my point of view is that the data model belongs to the middle layer, even when it is delivered with the framework and has the namespace of framework. I was the one who defined how the data model will look like. Even if the transport layer is replaced with something else, the data model will have to stay the same, but may be with a different namespace. The easiest solution will be to have a "#define" or "using" to rename the namespace with my own. Jul 10, 2018 at 7:12
  • @user2219907: it is not important if "you was the one who defined how the data model will look like", or if the comm layer is part of the middle layer or not. It is important if you/your team has the thing still under your control, and that it already cares for "not having to replace every single instance" in case you need to change the comm technology. This is the argument of your colleague you need to focus on.
    – Doc Brown
    Jul 10, 2018 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.