Creating a service
A major benefit to creating a service layer is the fact that it creates a simpler, easier interface to interact with and access the data through the larger collection of packages and Class libraries within your code base.
The service layer can also manage the instantiation of related objects.
To highlight the effectiveness of using a Service layer (or Facade Pattern) in your larger applications, the code used in this chapter has grown. We now have not only a component package dealing with User interactions (the Bean, DAO, and Gateway), we also have a package dealing with the user's address, which is available in the complete code download for this chapter.
Let's take a look at the onApplicatonStart()
method as it currently stands within the Application.cfc file.
<cffunction name="onApplicationStart" output="false"> <!--- Instantiate the Datasource object. ---> <cfset var objDatasource = createObject('component', 'com.packtApp.oop.beans.Datasource').init( DSName...