Procedural Code Vs Object Oriented CF code Object Oriented approach in CF Why OOPs Types of components Complexities in Object Oriented approach Introduce Factories Problems addressed and not addressed by factories Introduce CodlSpring framework Initialization and dependency handled by Coldspring Summary
Procedural ltCFINCLUDEgt tags Coldfusion Custom tags User defined Function Implemented using FuseBox 31 framework in VE
Object Oriented CFC ndash ColdFusion Components
ltCFCOMPONENTgt ltCFINVOKEgt ltCFOBJECTgt Implemented using FuseBox 41 framework in VE
Implementing OOPs in CF CFC - ltCFCOMPONENTgt Functions - ltCFFUNCTIONgt
ltCFARGUMENTgt ltCFRETURNgt Object Instance - ltCFINVOKEgt
ltCFINVOKEARGUMENTgt ltCFOBJECTgt createObject() init()
Properties - ltCFPROPERTYgt
Represents Real world objects and therefore gives a lot of meaning to the code
High Reusability Easy Maintenance Isolation of different layers (User
Interface Business Logic Data)
1 People Place Things Represent real world stuff Related objects are created as and when needed Usually core to the business model
2 Services and Infrastructure Represent concepts and processes Related objects are often other services and
infrastructure Data Access Objects Data source objects
Usually created at application startup
Problems in Object Creation createObject() ltcfobjectgt ltcfinvokegt
all require ldquopathnamesrdquo to CFCs Code is littered with hardcoded strings
specifying locations of CFCs Hard to move CFCs around or swap out one
implementation (CFC) for another Hard to unit test code because you cant
easily substitute a ldquomockrdquo CFC for the full object
Inside your controller codeltcfset var dsn = createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gt ltcfset variablesdao = createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( dsn ) gt
Problems with DependenciesIf the controller needs the data access object and the data access object needs the datasource object how do you create initialize them
Create datasource object Create data access object and
initialize with datasource object But whose responsibility should this
be
A factory ldquomakes thingsrdquo A factory object makes objects Move hardcoded paths into the factory
object ndash only one place to make changes now
Factory knows about dependencies Rest of your code depends on the factory
object ldquoFactory MethodrdquoPattern
Inside your factoryltcffunction name=ldquogetDatasourcerdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gtltcffunctiongt
ltcffunction name= ldquogetDAOrdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( getDatasource() )ltcffunctiongt
Inside your controller codeltcfset variablesdao = myFactorygetDAO() gtbull Where does myFactory come frombull Passed into controllerbull Created by controllerbull Or use applicationfactory insteadFactory created during application initialization ltcfset applicationfactory = createObject( ldquocomponentrdquoldquocfcsfactoryrdquo )init() gt
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs (or change implementation) by changing only
the factory codebull Some initialization can be handled by the factorybull But where does it get the initialization data
Problems Not Addressedbull Unit testing mocks mean changing the factory code all the timebull Factory needs to know dependenciesbull Initialization is still a pain
-Factory can be passed the initialization data
-Factory can contain the initialization data
- Factory can load data fromsomewhere (hmm cong les)
-Factory can pass back uninitialized objects (bad)
A testing factory and a regular factorybull Lots of duplicated codebull Have to change code to test different
parts of the applicationbull Can also solve the multiple database
support problem(a dataAccess object factory for MS SQLMySQL
Oracle)ldquoAbstract FactoryrdquoPatternbull Multiple factories with the same API
Selecting factories at startupltcfif dbType is ldquomysqlrdquogtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsmysqlfactoryrdquo )init() gtltcfelsegtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsoraclefactoryrdquo )init() gtltcfifgt
Problems AddressedAbility to create different sets of objects ndash swapping implementations unit testing (sort of)
Problems Not AddressedInitialization ndash partially solved but its still uglyDependencies ndash still hardcoded still has complex initialization issues
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
Procedural ltCFINCLUDEgt tags Coldfusion Custom tags User defined Function Implemented using FuseBox 31 framework in VE
Object Oriented CFC ndash ColdFusion Components
ltCFCOMPONENTgt ltCFINVOKEgt ltCFOBJECTgt Implemented using FuseBox 41 framework in VE
Implementing OOPs in CF CFC - ltCFCOMPONENTgt Functions - ltCFFUNCTIONgt
ltCFARGUMENTgt ltCFRETURNgt Object Instance - ltCFINVOKEgt
ltCFINVOKEARGUMENTgt ltCFOBJECTgt createObject() init()
Properties - ltCFPROPERTYgt
Represents Real world objects and therefore gives a lot of meaning to the code
High Reusability Easy Maintenance Isolation of different layers (User
Interface Business Logic Data)
1 People Place Things Represent real world stuff Related objects are created as and when needed Usually core to the business model
2 Services and Infrastructure Represent concepts and processes Related objects are often other services and
infrastructure Data Access Objects Data source objects
Usually created at application startup
Problems in Object Creation createObject() ltcfobjectgt ltcfinvokegt
all require ldquopathnamesrdquo to CFCs Code is littered with hardcoded strings
specifying locations of CFCs Hard to move CFCs around or swap out one
implementation (CFC) for another Hard to unit test code because you cant
easily substitute a ldquomockrdquo CFC for the full object
Inside your controller codeltcfset var dsn = createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gt ltcfset variablesdao = createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( dsn ) gt
Problems with DependenciesIf the controller needs the data access object and the data access object needs the datasource object how do you create initialize them
Create datasource object Create data access object and
initialize with datasource object But whose responsibility should this
be
A factory ldquomakes thingsrdquo A factory object makes objects Move hardcoded paths into the factory
object ndash only one place to make changes now
Factory knows about dependencies Rest of your code depends on the factory
object ldquoFactory MethodrdquoPattern
Inside your factoryltcffunction name=ldquogetDatasourcerdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gtltcffunctiongt
ltcffunction name= ldquogetDAOrdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( getDatasource() )ltcffunctiongt
Inside your controller codeltcfset variablesdao = myFactorygetDAO() gtbull Where does myFactory come frombull Passed into controllerbull Created by controllerbull Or use applicationfactory insteadFactory created during application initialization ltcfset applicationfactory = createObject( ldquocomponentrdquoldquocfcsfactoryrdquo )init() gt
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs (or change implementation) by changing only
the factory codebull Some initialization can be handled by the factorybull But where does it get the initialization data
Problems Not Addressedbull Unit testing mocks mean changing the factory code all the timebull Factory needs to know dependenciesbull Initialization is still a pain
-Factory can be passed the initialization data
-Factory can contain the initialization data
- Factory can load data fromsomewhere (hmm cong les)
-Factory can pass back uninitialized objects (bad)
A testing factory and a regular factorybull Lots of duplicated codebull Have to change code to test different
parts of the applicationbull Can also solve the multiple database
support problem(a dataAccess object factory for MS SQLMySQL
Oracle)ldquoAbstract FactoryrdquoPatternbull Multiple factories with the same API
Selecting factories at startupltcfif dbType is ldquomysqlrdquogtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsmysqlfactoryrdquo )init() gtltcfelsegtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsoraclefactoryrdquo )init() gtltcfifgt
Problems AddressedAbility to create different sets of objects ndash swapping implementations unit testing (sort of)
Problems Not AddressedInitialization ndash partially solved but its still uglyDependencies ndash still hardcoded still has complex initialization issues
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
Implementing OOPs in CF CFC - ltCFCOMPONENTgt Functions - ltCFFUNCTIONgt
ltCFARGUMENTgt ltCFRETURNgt Object Instance - ltCFINVOKEgt
ltCFINVOKEARGUMENTgt ltCFOBJECTgt createObject() init()
Properties - ltCFPROPERTYgt
Represents Real world objects and therefore gives a lot of meaning to the code
High Reusability Easy Maintenance Isolation of different layers (User
Interface Business Logic Data)
1 People Place Things Represent real world stuff Related objects are created as and when needed Usually core to the business model
2 Services and Infrastructure Represent concepts and processes Related objects are often other services and
infrastructure Data Access Objects Data source objects
Usually created at application startup
Problems in Object Creation createObject() ltcfobjectgt ltcfinvokegt
all require ldquopathnamesrdquo to CFCs Code is littered with hardcoded strings
specifying locations of CFCs Hard to move CFCs around or swap out one
implementation (CFC) for another Hard to unit test code because you cant
easily substitute a ldquomockrdquo CFC for the full object
Inside your controller codeltcfset var dsn = createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gt ltcfset variablesdao = createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( dsn ) gt
Problems with DependenciesIf the controller needs the data access object and the data access object needs the datasource object how do you create initialize them
Create datasource object Create data access object and
initialize with datasource object But whose responsibility should this
be
A factory ldquomakes thingsrdquo A factory object makes objects Move hardcoded paths into the factory
object ndash only one place to make changes now
Factory knows about dependencies Rest of your code depends on the factory
object ldquoFactory MethodrdquoPattern
Inside your factoryltcffunction name=ldquogetDatasourcerdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gtltcffunctiongt
ltcffunction name= ldquogetDAOrdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( getDatasource() )ltcffunctiongt
Inside your controller codeltcfset variablesdao = myFactorygetDAO() gtbull Where does myFactory come frombull Passed into controllerbull Created by controllerbull Or use applicationfactory insteadFactory created during application initialization ltcfset applicationfactory = createObject( ldquocomponentrdquoldquocfcsfactoryrdquo )init() gt
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs (or change implementation) by changing only
the factory codebull Some initialization can be handled by the factorybull But where does it get the initialization data
Problems Not Addressedbull Unit testing mocks mean changing the factory code all the timebull Factory needs to know dependenciesbull Initialization is still a pain
-Factory can be passed the initialization data
-Factory can contain the initialization data
- Factory can load data fromsomewhere (hmm cong les)
-Factory can pass back uninitialized objects (bad)
A testing factory and a regular factorybull Lots of duplicated codebull Have to change code to test different
parts of the applicationbull Can also solve the multiple database
support problem(a dataAccess object factory for MS SQLMySQL
Oracle)ldquoAbstract FactoryrdquoPatternbull Multiple factories with the same API
Selecting factories at startupltcfif dbType is ldquomysqlrdquogtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsmysqlfactoryrdquo )init() gtltcfelsegtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsoraclefactoryrdquo )init() gtltcfifgt
Problems AddressedAbility to create different sets of objects ndash swapping implementations unit testing (sort of)
Problems Not AddressedInitialization ndash partially solved but its still uglyDependencies ndash still hardcoded still has complex initialization issues
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
Represents Real world objects and therefore gives a lot of meaning to the code
High Reusability Easy Maintenance Isolation of different layers (User
Interface Business Logic Data)
1 People Place Things Represent real world stuff Related objects are created as and when needed Usually core to the business model
2 Services and Infrastructure Represent concepts and processes Related objects are often other services and
infrastructure Data Access Objects Data source objects
Usually created at application startup
Problems in Object Creation createObject() ltcfobjectgt ltcfinvokegt
all require ldquopathnamesrdquo to CFCs Code is littered with hardcoded strings
specifying locations of CFCs Hard to move CFCs around or swap out one
implementation (CFC) for another Hard to unit test code because you cant
easily substitute a ldquomockrdquo CFC for the full object
Inside your controller codeltcfset var dsn = createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gt ltcfset variablesdao = createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( dsn ) gt
Problems with DependenciesIf the controller needs the data access object and the data access object needs the datasource object how do you create initialize them
Create datasource object Create data access object and
initialize with datasource object But whose responsibility should this
be
A factory ldquomakes thingsrdquo A factory object makes objects Move hardcoded paths into the factory
object ndash only one place to make changes now
Factory knows about dependencies Rest of your code depends on the factory
object ldquoFactory MethodrdquoPattern
Inside your factoryltcffunction name=ldquogetDatasourcerdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gtltcffunctiongt
ltcffunction name= ldquogetDAOrdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( getDatasource() )ltcffunctiongt
Inside your controller codeltcfset variablesdao = myFactorygetDAO() gtbull Where does myFactory come frombull Passed into controllerbull Created by controllerbull Or use applicationfactory insteadFactory created during application initialization ltcfset applicationfactory = createObject( ldquocomponentrdquoldquocfcsfactoryrdquo )init() gt
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs (or change implementation) by changing only
the factory codebull Some initialization can be handled by the factorybull But where does it get the initialization data
Problems Not Addressedbull Unit testing mocks mean changing the factory code all the timebull Factory needs to know dependenciesbull Initialization is still a pain
-Factory can be passed the initialization data
-Factory can contain the initialization data
- Factory can load data fromsomewhere (hmm cong les)
-Factory can pass back uninitialized objects (bad)
A testing factory and a regular factorybull Lots of duplicated codebull Have to change code to test different
parts of the applicationbull Can also solve the multiple database
support problem(a dataAccess object factory for MS SQLMySQL
Oracle)ldquoAbstract FactoryrdquoPatternbull Multiple factories with the same API
Selecting factories at startupltcfif dbType is ldquomysqlrdquogtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsmysqlfactoryrdquo )init() gtltcfelsegtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsoraclefactoryrdquo )init() gtltcfifgt
Problems AddressedAbility to create different sets of objects ndash swapping implementations unit testing (sort of)
Problems Not AddressedInitialization ndash partially solved but its still uglyDependencies ndash still hardcoded still has complex initialization issues
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
1 People Place Things Represent real world stuff Related objects are created as and when needed Usually core to the business model
2 Services and Infrastructure Represent concepts and processes Related objects are often other services and
infrastructure Data Access Objects Data source objects
Usually created at application startup
Problems in Object Creation createObject() ltcfobjectgt ltcfinvokegt
all require ldquopathnamesrdquo to CFCs Code is littered with hardcoded strings
specifying locations of CFCs Hard to move CFCs around or swap out one
implementation (CFC) for another Hard to unit test code because you cant
easily substitute a ldquomockrdquo CFC for the full object
Inside your controller codeltcfset var dsn = createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gt ltcfset variablesdao = createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( dsn ) gt
Problems with DependenciesIf the controller needs the data access object and the data access object needs the datasource object how do you create initialize them
Create datasource object Create data access object and
initialize with datasource object But whose responsibility should this
be
A factory ldquomakes thingsrdquo A factory object makes objects Move hardcoded paths into the factory
object ndash only one place to make changes now
Factory knows about dependencies Rest of your code depends on the factory
object ldquoFactory MethodrdquoPattern
Inside your factoryltcffunction name=ldquogetDatasourcerdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gtltcffunctiongt
ltcffunction name= ldquogetDAOrdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( getDatasource() )ltcffunctiongt
Inside your controller codeltcfset variablesdao = myFactorygetDAO() gtbull Where does myFactory come frombull Passed into controllerbull Created by controllerbull Or use applicationfactory insteadFactory created during application initialization ltcfset applicationfactory = createObject( ldquocomponentrdquoldquocfcsfactoryrdquo )init() gt
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs (or change implementation) by changing only
the factory codebull Some initialization can be handled by the factorybull But where does it get the initialization data
Problems Not Addressedbull Unit testing mocks mean changing the factory code all the timebull Factory needs to know dependenciesbull Initialization is still a pain
-Factory can be passed the initialization data
-Factory can contain the initialization data
- Factory can load data fromsomewhere (hmm cong les)
-Factory can pass back uninitialized objects (bad)
A testing factory and a regular factorybull Lots of duplicated codebull Have to change code to test different
parts of the applicationbull Can also solve the multiple database
support problem(a dataAccess object factory for MS SQLMySQL
Oracle)ldquoAbstract FactoryrdquoPatternbull Multiple factories with the same API
Selecting factories at startupltcfif dbType is ldquomysqlrdquogtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsmysqlfactoryrdquo )init() gtltcfelsegtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsoraclefactoryrdquo )init() gtltcfifgt
Problems AddressedAbility to create different sets of objects ndash swapping implementations unit testing (sort of)
Problems Not AddressedInitialization ndash partially solved but its still uglyDependencies ndash still hardcoded still has complex initialization issues
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
Problems in Object Creation createObject() ltcfobjectgt ltcfinvokegt
all require ldquopathnamesrdquo to CFCs Code is littered with hardcoded strings
specifying locations of CFCs Hard to move CFCs around or swap out one
implementation (CFC) for another Hard to unit test code because you cant
easily substitute a ldquomockrdquo CFC for the full object
Inside your controller codeltcfset var dsn = createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gt ltcfset variablesdao = createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( dsn ) gt
Problems with DependenciesIf the controller needs the data access object and the data access object needs the datasource object how do you create initialize them
Create datasource object Create data access object and
initialize with datasource object But whose responsibility should this
be
A factory ldquomakes thingsrdquo A factory object makes objects Move hardcoded paths into the factory
object ndash only one place to make changes now
Factory knows about dependencies Rest of your code depends on the factory
object ldquoFactory MethodrdquoPattern
Inside your factoryltcffunction name=ldquogetDatasourcerdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gtltcffunctiongt
ltcffunction name= ldquogetDAOrdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( getDatasource() )ltcffunctiongt
Inside your controller codeltcfset variablesdao = myFactorygetDAO() gtbull Where does myFactory come frombull Passed into controllerbull Created by controllerbull Or use applicationfactory insteadFactory created during application initialization ltcfset applicationfactory = createObject( ldquocomponentrdquoldquocfcsfactoryrdquo )init() gt
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs (or change implementation) by changing only
the factory codebull Some initialization can be handled by the factorybull But where does it get the initialization data
Problems Not Addressedbull Unit testing mocks mean changing the factory code all the timebull Factory needs to know dependenciesbull Initialization is still a pain
-Factory can be passed the initialization data
-Factory can contain the initialization data
- Factory can load data fromsomewhere (hmm cong les)
-Factory can pass back uninitialized objects (bad)
A testing factory and a regular factorybull Lots of duplicated codebull Have to change code to test different
parts of the applicationbull Can also solve the multiple database
support problem(a dataAccess object factory for MS SQLMySQL
Oracle)ldquoAbstract FactoryrdquoPatternbull Multiple factories with the same API
Selecting factories at startupltcfif dbType is ldquomysqlrdquogtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsmysqlfactoryrdquo )init() gtltcfelsegtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsoraclefactoryrdquo )init() gtltcfifgt
Problems AddressedAbility to create different sets of objects ndash swapping implementations unit testing (sort of)
Problems Not AddressedInitialization ndash partially solved but its still uglyDependencies ndash still hardcoded still has complex initialization issues
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
Problems with DependenciesIf the controller needs the data access object and the data access object needs the datasource object how do you create initialize them
Create datasource object Create data access object and
initialize with datasource object But whose responsibility should this
be
A factory ldquomakes thingsrdquo A factory object makes objects Move hardcoded paths into the factory
object ndash only one place to make changes now
Factory knows about dependencies Rest of your code depends on the factory
object ldquoFactory MethodrdquoPattern
Inside your factoryltcffunction name=ldquogetDatasourcerdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gtltcffunctiongt
ltcffunction name= ldquogetDAOrdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( getDatasource() )ltcffunctiongt
Inside your controller codeltcfset variablesdao = myFactorygetDAO() gtbull Where does myFactory come frombull Passed into controllerbull Created by controllerbull Or use applicationfactory insteadFactory created during application initialization ltcfset applicationfactory = createObject( ldquocomponentrdquoldquocfcsfactoryrdquo )init() gt
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs (or change implementation) by changing only
the factory codebull Some initialization can be handled by the factorybull But where does it get the initialization data
Problems Not Addressedbull Unit testing mocks mean changing the factory code all the timebull Factory needs to know dependenciesbull Initialization is still a pain
-Factory can be passed the initialization data
-Factory can contain the initialization data
- Factory can load data fromsomewhere (hmm cong les)
-Factory can pass back uninitialized objects (bad)
A testing factory and a regular factorybull Lots of duplicated codebull Have to change code to test different
parts of the applicationbull Can also solve the multiple database
support problem(a dataAccess object factory for MS SQLMySQL
Oracle)ldquoAbstract FactoryrdquoPatternbull Multiple factories with the same API
Selecting factories at startupltcfif dbType is ldquomysqlrdquogtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsmysqlfactoryrdquo )init() gtltcfelsegtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsoraclefactoryrdquo )init() gtltcfifgt
Problems AddressedAbility to create different sets of objects ndash swapping implementations unit testing (sort of)
Problems Not AddressedInitialization ndash partially solved but its still uglyDependencies ndash still hardcoded still has complex initialization issues
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
A factory ldquomakes thingsrdquo A factory object makes objects Move hardcoded paths into the factory
object ndash only one place to make changes now
Factory knows about dependencies Rest of your code depends on the factory
object ldquoFactory MethodrdquoPattern
Inside your factoryltcffunction name=ldquogetDatasourcerdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsdatasourcerdquo )init( ldquotestdbrdquo ) gtltcffunctiongt
ltcffunction name= ldquogetDAOrdquogtltcfreturn createObject( ldquocomponentrdquoldquocfcsmysqldaordquo )init( getDatasource() )ltcffunctiongt
Inside your controller codeltcfset variablesdao = myFactorygetDAO() gtbull Where does myFactory come frombull Passed into controllerbull Created by controllerbull Or use applicationfactory insteadFactory created during application initialization ltcfset applicationfactory = createObject( ldquocomponentrdquoldquocfcsfactoryrdquo )init() gt
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs (or change implementation) by changing only
the factory codebull Some initialization can be handled by the factorybull But where does it get the initialization data
Problems Not Addressedbull Unit testing mocks mean changing the factory code all the timebull Factory needs to know dependenciesbull Initialization is still a pain
-Factory can be passed the initialization data
-Factory can contain the initialization data
- Factory can load data fromsomewhere (hmm cong les)
-Factory can pass back uninitialized objects (bad)
A testing factory and a regular factorybull Lots of duplicated codebull Have to change code to test different
parts of the applicationbull Can also solve the multiple database
support problem(a dataAccess object factory for MS SQLMySQL
Oracle)ldquoAbstract FactoryrdquoPatternbull Multiple factories with the same API
Selecting factories at startupltcfif dbType is ldquomysqlrdquogtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsmysqlfactoryrdquo )init() gtltcfelsegtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsoraclefactoryrdquo )init() gtltcfifgt
Problems AddressedAbility to create different sets of objects ndash swapping implementations unit testing (sort of)
Problems Not AddressedInitialization ndash partially solved but its still uglyDependencies ndash still hardcoded still has complex initialization issues
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs (or change implementation) by changing only
the factory codebull Some initialization can be handled by the factorybull But where does it get the initialization data
Problems Not Addressedbull Unit testing mocks mean changing the factory code all the timebull Factory needs to know dependenciesbull Initialization is still a pain
-Factory can be passed the initialization data
-Factory can contain the initialization data
- Factory can load data fromsomewhere (hmm cong les)
-Factory can pass back uninitialized objects (bad)
A testing factory and a regular factorybull Lots of duplicated codebull Have to change code to test different
parts of the applicationbull Can also solve the multiple database
support problem(a dataAccess object factory for MS SQLMySQL
Oracle)ldquoAbstract FactoryrdquoPatternbull Multiple factories with the same API
Selecting factories at startupltcfif dbType is ldquomysqlrdquogtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsmysqlfactoryrdquo )init() gtltcfelsegtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsoraclefactoryrdquo )init() gtltcfifgt
Problems AddressedAbility to create different sets of objects ndash swapping implementations unit testing (sort of)
Problems Not AddressedInitialization ndash partially solved but its still uglyDependencies ndash still hardcoded still has complex initialization issues
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
A testing factory and a regular factorybull Lots of duplicated codebull Have to change code to test different
parts of the applicationbull Can also solve the multiple database
support problem(a dataAccess object factory for MS SQLMySQL
Oracle)ldquoAbstract FactoryrdquoPatternbull Multiple factories with the same API
Selecting factories at startupltcfif dbType is ldquomysqlrdquogtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsmysqlfactoryrdquo )init() gtltcfelsegtltcfset applicationfactory =createObject( ldquocomponentrdquoldquocfcsoraclefactoryrdquo )init() gtltcfifgt
Problems AddressedAbility to create different sets of objects ndash swapping implementations unit testing (sort of)
Problems Not AddressedInitialization ndash partially solved but its still uglyDependencies ndash still hardcoded still has complex initialization issues
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
Problems AddressedAbility to create different sets of objects ndash swapping implementations unit testing (sort of)
Problems Not AddressedInitialization ndash partially solved but its still uglyDependencies ndash still hardcoded still has complex initialization issues
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
Instead of trying to handcode each factory and managing all of the dependencies and initializations why not use a genericfactory
ChiliBeans- Included with Model-Glue- Effectively deprecated
ColdSpring- Muchmore than just a factory
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
bull A container to manage your CFCsbull httpcoldspringframeworkorgbull XML configuration file specifies
bull CFC pathnames and type namesbull Initialization (via constructors or setters)bull Dependencies
bull Ask ColdSpring for ldquofoordquoand get a fully initialized resolved object of the appropriate type
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
Problems Addressedbull No hardcoded paths in application codebull Can move CFCs or change
implementation just by changing XML declarations
bull All initialization handledbull All dependencies managedbull Create different objects
By swapping XML le or just changing the XML declarations
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
Datasource CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquonamerdquogtltcfset variablesname = argumentsnamegtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetNamerdquogtltcfreturn variablesnamegtltcffunctiongtltcfcomponentgt
DAO CFC (abbreviated)1048576 ltcfcomponentgtltcffunction name=ldquoinitrdquogtltcfargument name=ldquodsnrdquogtltcfset variablesdsn = argumentsdsngtltcfreturn thisgtltcffunctiongtltcffunction name=ldquogetDSNrdquogtltcfreturn variablesdsngtltcffunctiongtltcfcomponentgt
Application Initializationltcfset applicationcs = createObject(ldquocomponentrdquoldquocoldspringbeansDefaultXmlFactoryrdquo)init() gtltcfset applicationcsloadBeans(expandPath(ldquocsxmlrdquo)) gt
Application Codeltcfset dao = applicationcsgetBean(ldquodaordquo) gtReturns a fully initialized data access objectltcfset dsn = daogetDSN() gtColdSpring resolved the dependency and created (and initialized) the datasource bean first then created the data access object bean and initialized it with the datasource bean
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)
XML Congurationltbeansgtltbean id=ldquodaordquo
type=ldquocfcsmysqldaordquogtltconstructor-arg name=ldquodsnrdquogtltbean type=ldquocfcsdatasourcerdquogtltconstructor-arg name=ldquonamerdquogtltvaluegttestdbltvaluegtltconstructor-arggtltbeangtltconstructor-arggtltbeangtltbeansgt
XML Examined (1) ltbean id=ldquodaordquo type=ldquocfcsmysqldaordquogt Specifies that ldquodaordquo resolves to cfcsmysqldao type ndash can easily change to cfcsoracledao etcltconstructor-arg name=ldquodsnrdquogt Specifies a constructor argument ndash ColdSpring creates the argument value (a bean) and passes it into the constructor automaticallyCould use ltpropertygt instead and ColdSpring would callsetXxx()method to set the property
XML Examined (2)ltbean type=ldquocfcsdatasourcerdquogt Unnamed object passed toldquodaordquo constructorltconstructor-arg name=ldquonamerdquogtSpecifies constructor argument for this datasource beanltvaluegttestdbltvaluegtSpecifies the (string) value passed to the constructorobjinit(name=ldquotestdbrdquo)