I am working on a web application that has to present charts on different pages. Each page corresponds to a Controller, and each Controller that needs a chart has an interface to a ChartService. The service requests a chart from a third party vendor. It then returns an image wrapped up in some HTML with JavaScript as a string directly into the output stream. The ChartService needs to be supplied with data and some other parameters like time period and template file.
Should I have the charting functionality abstracted into its own Controller? Each different type of chart could be served by a different Action Method on the ChartController.
But would it be a problem then that I’m serving some of my pages from multiple Controllers? What are the guidelines to determine when functionality should be given its own controller?
Sounds like you needn’t change anything at all. You’ve abstracted away the third-party service inside of a wrapper so that your controllers don’t depend directly on that specific service. Creating a new controller in this case would amount to creating a wrapper around your wrapper.
Create a new controller when you want to add behavior to the application.