How about objContacts.set("name","Joseph")
 and then objContacts.get("name")?

If there is one get and set for each field, do you think the objContacts.setName("Joseph") approach would make a CFC with to many functions?

Please explain the reason why it's an inner class and why it's bad.

The code below is an example of the code generation output currently in the next release. When the component object is initialized, all the variables for the columns get set with the default values ready for any database transaction.

One alternative is to have a getter and setter CFC invoke this CFC as a data access layer. The code CFSQL Tool generates is one layer above the database. I can very easily understand encapsulating it with another CFC where it would be the data access object that the application sees and not the CFSQL Tool's CFC.



======== Example code from the Switchbox CFSQL Tool ============
<cfcomponent extends="Office" displayname="objContacts">
<!--- Set instance variables --->
<cfscript>
this.$ContactsID = ""; //Null: No , Type: int, Char Len:, Num Pre: 10, Radix: 10, Scale: 0, Time Prec:
this.$Name = ""; //Null: No , Type: varchar, Char Len:50, Num Pre: , Radix: , Scale: , Time Prec:
this.$DateCreate = getdate(); //Null: No , Type: datetime, Char Len:, Num Pre: 23, Radix: , Scale: 3, Time Prec: 3
</cfscript>


<!--- ************************************************************ --->
<!--- ************************************************************ --->
<cffunction name="init" returntype="struct" hint="Init for the CFC" output="no">
<cfreturn this>
</cffunction>


<!--- ************************************************************ --->
<!--- ************************************************************ --->
<cffunction name="SetInit" returntype="boolean" hint="SetInit for the CFC" output="no">
<cfargument name="DSN" type="string" default="">
<cfset this.DSN = Arguments.DSN >
<cfreturn TRUE>
</cffunction>
<!--- ************************************************************ --->
<!--- ************************************************************ --->
<cffunction name="InstanceActorIn" returntype="void" output="no">
<cfscript>
this.$ContactsID = Request.IN.ContactsID;
this.$Name = Request.IN.Name;
this.$DateCreate = Request.IN.DateCreate;
</cfscript>
<cfreturn>
</cffunction>
<!--- ************************************************************ --->


<!--- ************************************************************ --->
<cffunction name="Create" returntype="query">
<cfargument name="theParams" type="struct" required="yes" >
<cfargument name="DSN" type="string" default="#this.DSN#">
<cfquery name="qContacts_INS" datasource="#Arguments.DSN#" maxrows=-1 >
BEGIN TRANSACTION
INSERT INTO dbo.Contacts
(
[Name],
)
VALUES
(
<cfqueryparam value="#theParams.Name#" cfsqltype="CF_SQL_varchar" >,
)


          SELECT  [ContactsID],[DateCreate]
          FROM dbo.Contacts
          WHERE ContactsID = SCOPE_IDENTITY()
          COMMIT TRAN
     </cfquery>
<cfreturn qContacts_INS >
</cffunction>

<!--- ************************************************************ --->

</cfcomponent>

At 09:53 AM 7/30/2004, you wrote:
approach 3:

create getters/setters in CFC for all fields. Values are set either
directly into variables scope, or into an instance struct within the
variables scope.

CF code would then be:  objContacts.setName("Joseph");

The data members should definitely be in the variables scope and not
the this scope, and I don't like the dollar sign nomenclature because to
me it means an inner class (and to CF when working w/ java objects).


-Dave



>>> [EMAIL PROTECTED] 7/30/2004 11:45:17 AM >>>
This is a request for comments about an approach I am considering for
CFSQLTool's code generation for CFC.

Background. Currently the CFC code generated with CFSQLTool does not
include a feature that does instance variables for a table's CRUD CFC.
I
would like to add that feature.

Example.
   SQL   Table: Contacts
           ContactsID
             Name
             DateCreate

    File: Contacts.CFC

    CF: objContacts = createObject("component","Contacts");


Problem. CF with getmetadata or cfdump makes no type distinction between variable and function namespaces.

  Approach 1. Create a structure, instance
                           instance = StructNew();
                     instance.Name = "";

      So in code say, objContacts.instance.Name = "Joseph";

  Approach 2.  Use the this scope with $ var name
                          this.$Name = "";

        So in code say, objContacts.$Name = "Joseph";

Currently, I like Approach 2 the best. It distinguishes variables names

from function names. Less coding than an instance structure.  But I
would
like to hear other comments or other approaches.

Joseph



-----------------------------------------------------------------------
http://www.switch-box.org/CFSQLTool/Download/

Switch_box                      MediaFirm, Inc.
www.Switch-box.org             Loveland, CO  USA
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

----------------------------------------------------------------------- http://www.switch-box.org/CFSQLTool/Download/

Switch_box                      MediaFirm, Inc.
www.Switch-box.org              Loveland, CO  USA

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to