Skip to content

Controllers

Scott Reeves edited this page Feb 22, 2021 · 4 revisions

Controllers are VBA classes that are the conductors of the orchestra in xHV. They invoke Services to manage the flow of data into and out of Models, and they are responsible for building Views.

Controllers know nothing of how a Service does it's work, nor does it care which service does it. Controllers are programmed to use interfaces to hand off work to Services. Any Service that implements the required Interface is all the Controller needs to do it's job.

Controllers utilize Dependency Injection to wire up which Services respond to which Interfaces.

Here's where a bit of blurring of the lines occurs. In xHV, Controllers know too much about what Views are doing because in this implementation, Controllers fetch a View Template from disk and build the full DOM during the Interpolation phase.

Additionally, Controllers are responsible for containing the Event Handlers that the WebBrowser control will call.

Also, they break the Single Responsibility Pricipal because they are also directly invovled with taking data that's in the Model and properly formatting the View template to show it (especially in a table or list).

Controllers follow these conventions:

  • Controllers are CLASSES
  • {Route}Controller.cls
  • They rely on Dependency Injection for Services
  • They contain all the logic necessary to marshall data to and from Views by way of Models
  • They assemble Views at runtime from Components
Clone this wiki locally