0
我正在處理與這些4個字段(每個不同名稱&函數)的約30個實例的表單數據。有沒有辦法讓這個更易於管理?如何優化這個bug的邏輯?
<!--- Lifeguard Instructor --->
<!--- Is the date defined? --->
<cfif len(Trim(form.lifeguardInstrcutorExp)) EQ 0>
<cfinvokeargument name="lifeguardInstrcutorExp"
value="#defaultDate#">
<cfelse>
<cfinvokeargument name="lifeguardInstrcutorExp"
value="#CreateODBCDate(Form.lifeguardInstrcutorExp)#">
</cfif>
<!--- Is a Company defined? --->
<cfif len(Trim(form.lifeguardInstrcutorCompany)) EQ 0>
<cfinvokeargument name="lifeguardInstrcutorCompany" value="">
<cfelse>
<cfinvokeargument name="lifeguardInstrcutorCompany"
value="#Trim(Form.lifeguardInstrcutorCompany)#">
</cfif>
<!--- Has a file been specificed? --->
<cfif not len(Trim(form.lifeguardInstrcutorImage)) EQ 0>
<cffile action="upload" accept="#defaultFileAccepted#"
filefield="lifeguardInstrcutorImage"
destination="#destination#"
nameConflict="makeUnique">
<cfinvokeargument name="lifeguardInstrcutorImage"
value="#pathOfFile##cffile.serverFile#">
<cfelse>
</cfif>
<!--- Do We have a hard copy? --->
<cfinvokeargument name="lifeguardInstrcutorOnFile"
value="#Trim(form.lifeguardInstrcutorOnFile)#">
不知道更多,就好像你可以移動一些邏輯到您呼叫的功能。讓函數做更多的工作,例如忽略空字符串或爲某些參數設置「默認」。什麼是'#defaultDate#'? (此外,「公司」檢查似乎沒有做任何超越修剪)。 – Leigh
您可以通過代碼(http://www.pastebin.com)的大量代碼來查看項目被重複的位置以及它們之間的偏差嗎? – Nate