<cfcomponent output="false" displayname="fantasyteam" hint="I am a fantasyteam.">
<cfset variables.instance = structNew()>
<cfset variables.instance.id = 0>
<cfset variables.instance.name = "">
<cfset variables.instance.owner = "">
<cfset variables.instance.draftorder = 0>
<cfset variables.instance.players = 0>
<cffunction name="init" access="public" returntype="any" output="no">
<cfargument name="id" required="no" type="numeric" default="0">
<cfargument name="name" required="no" type="string" default="">
<cfargument name="owner" required="no" type="string" default="">
<cfargument name="draftorder" required="no" type="numeric" default="0">
<cfargument name="players" required="no" type="array" default="#arrayNew(1)#">
<cfset setInstanceMemento(arguments)>
<cfreturn this />
</cffunction>
<cffunction name="getId" access="public" output="no" returntype="numeric">
<cfreturn variables.instance.id>
</cffunction>
<cffunction name="setId" access="public" output="no" returntype="void">
<cfargument name="id" required="yes" type="numeric">
<cfset variables.instance.id = arguments.id>
</cffunction>
<cffunction name="getName" access="public" output="no" returntype="string">
<cfreturn variables.instance.name>
</cffunction>
<cffunction name="setName" access="public" output="no" returntype="void">
<cfargument name="name" required="yes" type="string">
<cfset variables.instance.name = arguments.name>
</cffunction>
<cffunction name="getOwner" access="public" output="no" returntype="string">
<cfreturn variables.instance.owner >
</cffunction>
<cffunction name="setOwner" access="public" output="no" returntype="void">
<cfargument name="owner" required="yes" type="string">
<cfset variables.instance.owner = arguments.owner>
</cffunction>
<cffunction name="getDraftorder" access="public" output="no" returntype="numeric">
<cfreturn variables.instance.draftorder>
</cffunction>
<cffunction name="setDraftorder" access="public" output="no" returntype="void">
<cfargument name="draftorder" required="yes" type="numeric">
<cfset variables.instance.draftorder = arguments.draftorder>
</cffunction>
<cffunction name="getPlayers" access="public" output="no" returntype="array">
<cfreturn variables.instance.players>
</cffunction>
<cffunction name="setPlayers" access="public" output="no" returntype="void">
<cfargument name="players" required="yes" type="array">
<cfset variables.instance.players = arguments.players>
</cffunction>
<cffunction name="getInstanceMemento" access="public" returntype="struct" output="false">
<cfset var data = ""> <cfset var players = getPlayers()>
<cfset var i = 0>
<cfset data.id = getId()>
<cfset data.name = getName()>
<cfset data.owner = getOwner()>
<cfset data.draftorder = getDraftorder()>
<cfset data.players = arrayNew(1)>
<cfloop from="1" to="#arrayLen(players)#" index="i">
<cfset arrayAppend(data.players, players[i].getInstanceMemento())>
</cfloop>
<cfreturn data>
</cffunction>
<cffunction name="setInstanceMemento" access="public" returntype="void" output="false">
<cfargument name="data" type="struct" required="true">
<cfset setId(arguments.data.id)>
<cfset setName( arguments.data.name)>
<cfset setOwner(arguments.data.owner)>
<cfset setDraftorder(arguments.data.draftorder)>
<cfset setPlayers(arguments.data.players )>
</cffunction>
</cfcomponent>
On 2/12/06, Baz <[EMAIL PROTECTED]> wrote:
> I can show you an example of how I setup domain objects that are
> composed of other objects if you like.
If I like? I would love!
-----Original Message-----
From: [email protected]
[mailto: [email protected]] On Behalf Of Kurt Wiersma
Sent: Sunday, February 12, 2006 3:18 PM
To: [email protected]
Subject: [coldspring-dev] Many dependencies
I think Chris and Dave agree with me when I say I don't think you
should use CS for your domain objects. CS is great for service, DAO,
and gateway objects. This doesn't mean you cannot use your domain
objects with CS it is just that I don't believe it is best practice. I
can show you an example of how I setup domain objects that are
composed of other objects if you like. The key is to use a service
layer if you aren't already.
--Kurt
On 2/12/06, Baz <[EMAIL PROTECTED]> wrote:
>
> Sorry for the double post, I'm just so excited with everything that's
going
> on.
>
> If I have a Contact CFC that can have multiple phone #'s, emails, bank
> accounts, addresses, credit cards, echecks, profiles, etc., etc., etc.
> Should I be injecting ALL of those dependent objects into Contact at
init()
> even though very often only 1 of the 15 gets used? Is this a good time to
> inject the factory itself, instead of each dependent cfc, so that the
> dependent objects are created on demand rather than at init()? Should
there
> perhaps not even be a dependency defined here and every objects gets
called
> separately on its own?
>
> I appreciate ANY thoughts or opinions you may have about this setup.
>
> Cheers,
> Baz
>
>
>
>
