Frage

I am just learning Android, and I am trying to implement a Front Controller. I am using a Class which extends from BroadCastReceiver as a Front Controller:

public class FrontControllerReceiver extends BroadcastReceiver {} 

In this way, every time an Activity needs to start another Activity, or start a Service, or a Service needs to send a response, I send a broadcast. This broadcast is received by the Front Controller and it decides what to do.

What I need to know is whether this is a good programming practice, because I do think is not efficient.

What would be the suggestion to efficiently implement the Front Controller?

War es hilfreich?

Lösung

Just looking at the definition for Front Controller on Wikipedia - The pattern relates to the design of web applications. Android isn't a web application, it has its own framework and expected usage patterns. While using a Mediator may work for certain aspects once you know what you are doing, I would delay trying to enforce 'good' design practice until you get a handle on the existing Android framework.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top