1

While developing an application (mobile app for Android), our team always strives to use best development practices such as interfaces, layering and separation of concerns.

When it comes to reporting analytics events from our app, the requirements sometimes force us to send events with data that is stored and managed by multiple different app "components".

Some of this data is not directly available at the component/layer that does the reporting, nor at any central location in the application.

To me, this seems like it contradicts all the efforts of architecture and design that were made during the development of the application.

My question is:

What is the correct way to deal with this issue?

Is the problem in the requirements we received, or is it a common issue that a layered/modular application sometimes needs to make things "global" ? if so, what is the way to solve this issue while still reaping the benefits of development best practices?

3

One of the principles of layered structure is that every layer call only the layer below and receive callbacks. So if the reporting layer does not provide access to this data, it is fair to assume that the data is not accessible from any other layer above.

I don't think adding globals is a good idea. It makes the architecture inconsistent and adds very little (if any) value. I would rather add the missing functionality to the reporting layer. In this case the reporting layer could call the component(s) managing the data and forward it to the original caller.

There might be deeper considerations if the data itself is distributed among different components. But anyway, having a single interface for all the data will make the structure clear and easier to maintain.

  • Isn't a "single interface for all the data" the exact opposite of splitting the apps into layers and components? – liortal Mar 31 '14 at 11:15
  • 1
    Not at all. By introducing layers you separate functionality. For example, you have a layer to directly access database (all data in database is available through that layer), then you have another layer on top of it containing all the business logic, and then another layer as a simple functional interface over the business logic, etc. This last layer is a single interface to interact with data, and it still hides several layers behind it. – superM Mar 31 '14 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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