Pergunta

I have already built REST based API's in codeigniter framework for one of the app. The app lists all the businesses registered with the company ABC.

Now I am developing website for the same company ABC. I need to show the businesses registered with ABC in the website home page as well. And when a customer clicks on one of the business, it will show them all the details of the business.

Ex. A coffee shop is the registered business. When a customer clicks on the coffee shop it will show what they offer and where they are located etc etc.

The same details are also shown on native android and IOS app.

My question here is: Should I use the same controller(which holds business logic) that is used for requesting and showing details of coffee shop on mobile devices? or build another controller for showing the same details on website.

Is it a good practise to use the same controller for both mobile and web ?

Future: There are plans for developing mobile web based application as well probably using phonegap or something. The current website will be responsive as well.

My understanding of having same controller for both mobile and website 1) Single controller for both mobile and website means one change and it reflects in all devices or platforms.

Any other advantages or disadvantages? and also few best practises that say use same controller or API for both or use different for web and mobile.

Please let me know if the question needs to be elaborated. Thanks everyone for your valuable answers.

Foi útil?

Solução

There may be things that can be shown on the PC's big screen that you cannot show on the mobile's small screen.

You can make two controller classes, one for mobile and another for the web that extends your main class that contains the business logic.

In this way you can modify the common things in your main class and technology specific things in their respective classes.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top