Archives

We Have No Comment at This Time

No Comment

I love ThinkGeek.

A Made2Manage friend called me recently to ask for help decoding the Visual FoxPro from a M2M report. While talking to him over the phone, I remarked that it would be a lot easier if all of the old code revisions weren’t included with the finished reports. For example, take a look at the VFP for the Job Order Status (RPJOSS) report. I apologize for the excessive scrolling required to see it.


* RPjoss1.PRG      Job Summary
** RDZ 09/18/1997 - Modified SELECT statement in ELSE condition. WL 040135
* 4/16/98 - tlc - ECM Mods, Add Part Revision
**	10/26/2000	BY
**	UDRev feature
**	Added user-defined revision numbers
PARAMETERS	lcFilter, ;
			lcDateRange, ;
			lcSortRange, ;
			lcAdvFilter, ;
			lcOtherVariable, ;
			lcSortOrder

LOCAL	lcRevision, lcFacility, lnhandle

lcRevision = ''
lcFacility = ''

**	10/03/2002	WCY
**	CR 85148
**	Change query from m2mSelect to SQLEXEC and native VFP commands
lcfilter2 = STRTRAN(UPPER(lcFilter),["],['])
lcfilter2 = STRTRAN(UPPER(lcFilter2),[.T.],[1=1])
lcAdvFilter2 = STRTRAN(UPPER(lcAdvFilter),["],['])
lcAdvFilter2 = STRTRAN(UPPER(lcAdvFilter2),[.T.],[1=1])

lnHandle = CURSORGETPROP('ConnectHandle','jomast')

if type('lcOtherVariable') $ 'LU'
   lcOtherVariable=.F.
ELSE
	lcFacility = lcOtherVariable[1]
	lcRevision = lcOtherVariable[2]
ENDIF

select jodrtg
M2MSetOrder('jobnoop',,.F.)
set near on

**	Get the first field from the sort range to use as our group expression
sortgroup = substr(lcsortorder,1,at(',',lcsortorder)-1)

*	case lcsortorder = 'JOMAST.FPARTNO,JOMAST.FJOBNO'             && ECM
do case
	**	05/11/2001	WCY	Multi
	case lcsortorder = 'JOMAST.FAC,JOMAST.FPARTNO,JOMAST.FPARTREV,JOMAST.FJOBNO'            && ECM
		sortname = 'Part : '

	case lcsortorder = 'JOMAST.FJOBNO'
		sortname = 'JOB : '
		sortgroup = lcsortorder

	case lcsortorder = 'JOMAST.FSONO,JOMAST.FJOBNO'
		sortname = 'Sales Order : '

	case lcsortorder = 'JOMAST.FCOMPANY,JOMAST.FJOBNO'
		sortname = 'Customer : '

	case lcsortorder = 'JOMAST.FDDUE_DATE,JOMAST.FJOBNO'
		sortname = 'Due Date : '

	otherwise
		sortname = 'Part : '

endcase

**	10/08/2001	WCY
**	CR 79672
**	Do a LEFT OUTER JOIN on INMAST to allow non-stnadard parts
if sortname = 'Due Date : '
	**	05/11/2001	WCY	Multi
**	11/16/2001	WCY
**	CR 80711
**	In order for the LEFT OUTER JOIN to work correctly, INMAST must be joined to the table just before it in the FROM list
*!*		M2MSelect('SELECT distinct sortname + dtoc(' + sortgroup + ') as sortitem, jomast.fdescript, jomast.fstatus, ' + ;
*!*				'jomast.fjobno, jomast.fsono, ' + ;
*!*				'jomast.fac, jomast.fpartno, jomast.fpartrev, jomast.fcudrev, ' + ;
*!*				'IIF(NOT ISNULL(inmast.fluseudrev) AND inmast.fluseudrev = .t., jomast.fcudrev, jomast.fpartrev) AS fcdisprev, ' + ;
*!*				'jomast.fjob_name, jomast.fquantity, ' + ;
*!*				'jopact.ftotptime+jopact.ftotstime as acthours, ' + ;
*!*				'OPERCOMP(upper(jomast.fjobno)) as opercom, ' + ;
*!*				'OPERWORK(upper(jomast.fjobno)) as operwrk, ' + ;
*!*				'jomast.fddue_date, jomast.fact_rel, jomast.fopen_dt, jomast.factschdfn, ' + ;
*!*				'jomast.factschdst, jomast.frouting, jomast.fdfnshdate, jomast.fstrt_date ' + ;
*!*				'FROM m2mdata!jopact, m2mdata!jomast ' + ;
*!*				'LEFT OUTER JOIN m2mdata!inmast ' + ;
*!*					'ON inmast.fpartno = jomast.fpartno ' + ;
*!*					' AND  inmast.frev = jomast.fpartrev ' + ;
*!*					' AND  inmast.fac = jomast.fac ' + ;
*!*				'WHERE upper(jomast.fjobno) = upper(jopact.fjobno) ' + ;
*!*				' AND ' + lcfilter + ;
*!*				' AND ' + lcsortrange + ;
*!*				' AND ' + lcdaterange + ;
*!*				' AND ' + lcadvfilter + ' ' + ;
*!*				'And Jomast.fstatus <> ' + CHR(34) + 'STARTED' + CHR(34) + ' ' + ;
*!*				'And Jomast.fstatus <> ' + CHR(34) + 'CANCELLED' + CHR(34) + ' ' + ;
*!*				'ORDER BY ' + lcsortorder + ' ' + ;
*!*				'Into Cursor rpjoss',SET('DATASESSION'),,'')

**	10/03/2002	WCY
**	CR 85148
**	Change query from m2mSelect to SQLEXEC and native VFP commands
**	11/13/2002	WCY
**	CR 100825
**	Include the pct complete as a subquery
**	03/21/2003	WCY
**	CR 103890
**	Corrected field names, changing fcopencomp to opercom and fcopenwork to operwrk
	lcSQL = "SELECT  jomast.fdescript, " + ;
					"jomast.fstatus, " + ;
					"jomast.fjobno, " + ;
					"jomast.fsono, " + ;
					"jomast.fac, " + ;
					"jomast.fpartno, " + ;
					"jomast.fpartrev, " + ;
					"jomast.fcudrev, " + ;
					"CASE WHEN(NOT(inmast.fluseudrev IS NULL)) AND( inmast.fluseudrev = 1) " + ;
						"THEN jomast.fcudrev " + ;
						"ELSE jomast.fpartrev END AS fcdisprev, " + ;
					"jomast.fjob_name, " + ;
					"jomast.fquantity, " + ;
					"jopact.ftotptime + jopact.ftotstime AS acthours, " + ;
					"jomast.fddue_date, " + ;
					"jomast.fact_rel, " + ;
					"jomast.fopen_dt, " + ;
					"jomast.factschdfn, " + ;
					"jomast.factschdst, " + ;
					"jomast.frouting, " + ;
					"jomast.fdfnshdate, " + ;
					"jomast.fstrt_date, " + ;
					"CASE WHEN csrOperComp.countops <> 0 " + ;
						" THEN str(ROUND(csrOperComp.sumpct /csrOperComp.countops ,0),3)+'|' " + ;
						" ELSE '000|' END AS opercom,  " + ;
					"ISNULL(jodrtg.fpro_id, SPACE(7)) as operwrk " + ;
			"FROM jomast " + ;
			"LEFT OUTER JOIN inmast " + ;
				"ON inmast.fpartno = jomast.fpartno " + ;
				"AND inmast.frev = jomast.fpartrev " + ;
				"AND inmast.fac = jomast.fac " + ;
			"INNER JOIN jopact " + ;
				"ON jopact.fjobno = jomast.fjobno " + ;
			"INNER JOIN (SELECT fjobno, count(fjobno) as countops, sum(fnpct_comp) as sumpct " + ;
						"from jodrtg " + ;
						"group by fjobno) as csrOperComp " + ;
				"ON csrOperComp.fjobno = jomast.fjobno " + ;
			"LEFT OUTER JOIN (SELECT fjobno, MAX(foperno) as maxoper " + ;
							"from jodrtg " + ;
							"where fnpct_comp <> 0 " + ;
							"group by fjobno) as csrOperMatl " + ;
				"ON csrOperMatl.fjobno = jomast.fjobno " + ;
			"LEFT OUTER JOIN jodrtg " + ;
				"ON jodrtg.fjobno = csrOperMatl.fjobno " + ;
				"AND jodrtg.foperno = csrOperMatl.maxoper " + ;
			"WHERE " + FIXVFPWHERE(lcFilter2) + ;
			" AND " + FIXVFPWHERE(lcAdvFilter2) + ;
			" AND " + FIXVFPWHERE(lcSortRange) + " " + ;
			IIF(TYPE('lcFacility') <> 'L' AND NOT EMPTY(lcFacility), " AND jomast.fac = '" + lcFacility + "' ","") + ;
			IIF(TYPE('lcRevision') <> 'L' AND NOT EMPTY(lcRevision), " AND jomast.fpartrev = '" + lcRevision + "' ","") + ;
			"And Jomast.fstatus <> 'STARTED' " + ;
			"And Jomast.fstatus <> 'CANCELLED' "  + ;
			" ORDER BY " + ALLTRIM(lcSortOrder) 

	IF SQLEXEC(lnHandle,lcSql,"rpjoss_pre") < 0
		IF USED('rpjoss_pre')
			SELECT rpjoss_pre
			USE
		ENDIF
		RETURN .F.
	ENDIF

**	03/21/2003	WCY
**	CR 103890
**	There is no way to format the date that we will be using in the SORTITEM field correctly in SQL.
**	Our best bet is to get an intial cursor, then do a VFP select that will add the SORTITEM field.
	SELECT sortname + dtoc(rpjoss_pre.FDDUE_DATE) as sortitem, rpjoss_pre.* ;
	FROM rpjoss_pre ;
	INTO CURSOR rpjoss

**	11/13/2002	WCY
**	CR 100825
**	This code is no longer used
**	Step 2: create and populate a second cursor from the VFP functions
*!*		CREATE CURSOR rptmp2 ;
*!*			(fjobno c(LEN(rptmp1.fjobno)), ;
*!*			opercom c(4), ;
*!*			operwrk c(LEN(jodrtg.fpro_id)))
*!*		CREATE CURSOR rptmp2 ;
*!*			(fjobno c(LEN(rptmp1.fjobno)), ;
*!*			operwrk c(LEN(jodrtg.fpro_id)))
*!*
*!*		SELECT rptmp1
*!*		GO TOP
*!*		SCAN
*!*			INSERT INTO rptmp2 ;
*!*				(fjobno, operwrk) ;
*!*			VALUES ;
*!*				(rptmp1.fjobno, ;
*!*				OPERWORK(upper(rptmp1.fjobno)))
*!*		ENDSCAN

**	Step 3: combine the two cursors
**	lcSortOrder2 = STRTRAN(lcSortOrder, "JOMAST.", "rptmp1.")

*!*		SELECT	sortname + dtoc(FDDUE_DATE) as sortitem, fdescript, fstatus, rptmp1.fjobno, fsono, fac, fpartno, fpartrev, fcudrev, fcdisprev, ;
*!*				fjob_name, fquantity, acthours, rptmp2.opercom, rptmp2.operwrk, fddue_date, fact_rel, ;
*!*				fopen_dt, factschdfn, factschdst, frouting, fdfnshdate, fstrt_date ;
*!*		FROM rptmp1, rptmp2 ;
*!*		WHERE rptmp2.fjobno = rptmp1.fjobno ;
*!*		ORDER BY &lcSortOrder2. ;
*!*		INTO CURSOR rpjoss
*!*		SELECT	sortname + dtoc(FDDUE_DATE) as sortitem, fdescript, fstatus, rptmp1.fjobno, fsono, fac, fpartno, fpartrev, fcudrev, fcdisprev, ;
*!*				fjob_name, fquantity, acthours, fcopencomp as opercom, fcopenwork as operwrk, fddue_date, fact_rel, ;
*!*				fopen_dt, factschdfn, factschdst, frouting, fdfnshdate, fstrt_date ;
*!*		FROM rptmp1 ;
*!*		ORDER BY &lcSortOrder2. ;
*!*		INTO CURSOR rpjoss

else
*!*		SELECT distinct sortname + &sortgroup as sortitem, jomast.fdescript, jomast.fstatus,
*!*		jomast.fjobno, jomast.fsono, jomast.fpartno, jomast.fjob_name,
*!*		jopact.ftotptime+jopact.ftotstime as acthours,
*!*		OPERCOMP(upper(jomast.fjobno)) as opercom,
*!*		jomast.fddue_date, jomast.fact_rel, jomast.fopen_dt, jomast.factschdfn,
*!*		jomast.factschdst, jomast.frouting, jomast.fdfnshdate
*!*		FROM m2mdata!jomast, m2mdata!jopact
*!*		WHERE upper(jomast.fjobno) = upper(jopact.fjobno)
*!*	 	  AND &lcfilter AND &lcsortrange AND &lcdaterange AND &lcadvfilter
*!*		And Jomast.fstatus <> "STARTED"
*!*		And Jomast.fstatus <> "CANCELLED"
*!*		ORDER BY &lcsortorder
*!*		Into Cursor rpjoss

** RDZ 09/18/1997 - Modified SELECT statement in ELSE condition. WL 040135
** STARTED and CANCELLED jobs should be in report when report Sort Order is not by "Due Date"

	**	05/11/2001	WCY	Multi
**	11/16/2001	WCY
**	CR 80711
**	In order for the LEFT OUTER JOIN to work correctly, INMAST must be joined to the table just before it in the FROM list
*!*		M2MSelect('SELECT distinct sortname + ' + sortgroup + ' as sortitem, jomast.fdescript, jomast.fstatus, ' + ;
*!*				'jomast.fjobno, jomast.fsono, ' + ;
*!*				'jomast.fac, jomast.fpartno, jomast.fpartrev, jomast.fcudrev, ' + ;
*!*				'IIF(NOT ISNULL(inmast.fluseudrev) AND inmast.fluseudrev = .t., jomast.fcudrev, jomast.fpartrev) AS fcdisprev, ' + ;
*!*				'jomast.fjob_name, jomast.fquantity, ' + ;
*!*				'jopact.ftotptime+jopact.ftotstime as acthours, ' + ;
*!*				'OPERCOMP(upper(jomast.fjobno)) as opercom, ' + ;
*!*				'OPERWORK(upper(jomast.fjobno)) as operwrk, ' + ;
*!*				'jomast.fddue_date, jomast.fact_rel, jomast.fopen_dt, jomast.factschdfn, ' + ;
*!*				'jomast.factschdst, jomast.frouting, jomast.fdfnshdate, jomast.fstrt_date ' + ;
*!*				'FROM m2mdata!jopact, m2mdata!jomast ' + ;
*!*				'LEFT OUTER JOIN m2mdata!inmast ' + ;
*!*					'ON inmast.fpartno = jomast.fpartno ' + ;
*!*					' AND  inmast.frev = jomast.fpartrev ' + ;
*!*					' AND  inmast.fac = jomast.fac ' + ;
*!*				'WHERE upper(jomast.fjobno) = upper(jopact.fjobno) ' + ;
*!*				' AND ' + lcfilter + ;
*!*				' AND ' + lcsortrange + ;
*!*				' AND ' + lcdaterange + ;
*!*				' AND ' + lcadvfilter + ' ' + ;
*!*				'AND IIF(empty(' + V(lcRevision) + '),.T.,upper(jomast.fpartrev) = upper(' + V(LCRevision) + ')) ' + ;
*!*				'AND IIF(empty(' + V(lcFacility) + '),.T., jomast.fac = ' + V(lcFacility) + ') ' + ;
*!*				'ORDER BY ' + lcsortorder + ' ' + ;
*!*				'Into Cursor rpjoss',SET('DATASESSION'),,'')
**	10/03/2002	WCY
**	CR 85148
**	Change query from m2mSelect to SQLEXEC and native VFP commands
**	 Step 1: Create the cursor from the SQL tables
**	11/13/2002	WCY
**	CR 100825
**	Include the pct complete as a subquery
	lcSQL = "SELECT  '" + sortname + "' + " + sortgroup + " AS sortitem, " + ;
					"jomast.fdescript, " + ;
					"jomast.fstatus, " + ;
					"jomast.fjobno, " + ;
					"jomast.fsono, " + ;
					"jomast.fac, " + ;
					"jomast.fpartno, " + ;
					"jomast.fpartrev, " + ;
					"jomast.fcudrev, " + ;
					"CASE WHEN(NOT(inmast.fluseudrev IS NULL)) AND( inmast.fluseudrev = 1) " + ;
						"THEN jomast.fcudrev " + ;
						"ELSE jomast.fpartrev END AS fcdisprev, " + ;
					"jomast.fjob_name, " + ;
					"jomast.fquantity, " + ;
					"jopact.ftotptime + jopact.ftotstime AS acthours, " + ;
					"jomast.fddue_date, " + ;
					"jomast.fact_rel, " + ;
					"jomast.fopen_dt, " + ;
					"jomast.factschdfn, " + ;
					"jomast.factschdst, " + ;
					"jomast.frouting, " + ;
					"jomast.fdfnshdate, " + ;
					"jomast.fstrt_date, " + ;
					"CASE WHEN csrOperComp.countops <> 0 " + ;
						" THEN str(ROUND(csrOperComp.sumpct /csrOperComp.countops ,0),3)+'|' " + ;
						" ELSE '000|' END AS opercom,  " + ;
					"ISNULL(jodrtg.fpro_id, SPACE(7)) as operwrk " + ;
			"FROM jomast " + ;
			"LEFT OUTER JOIN inmast " + ;
				"ON inmast.fpartno = jomast.fpartno " + ;
				"AND inmast.frev = jomast.fpartrev " + ;
				"AND inmast.fac = jomast.fac " + ;
			"INNER JOIN jopact " + ;
				"ON jopact.fjobno = jomast.fjobno " + ;
			"INNER JOIN (SELECT fjobno, count(fjobno) as countops, sum(fnpct_comp) as sumpct " + ;
						"from jodrtg " + ;
						"group by fjobno) as csrOperComp " + ;
				"ON csrOperComp.fjobno = jomast.fjobno " + ;
			"LEFT OUTER JOIN (SELECT fjobno, MAX(foperno) as maxoper " + ;
							"from jodrtg " + ;
							"where fnpct_comp <> 0 " + ;
							"group by fjobno) as csrOperMatl " + ;
				"ON csrOperMatl.fjobno = jomast.fjobno " + ;
			"LEFT OUTER JOIN jodrtg " + ;
				"ON jodrtg.fjobno = csrOperMatl.fjobno " + ;
				"AND jodrtg.foperno = csrOperMatl.maxoper " + ;
			"WHERE " + FIXVFPWHERE(lcFilter2) + ;
			" AND " + FIXVFPWHERE(lcAdvFilter2) + ;
			" AND " + FIXVFPWHERE(lcSortRange) + " " + ;
			IIF(TYPE('lcFacility') <> 'L' AND NOT EMPTY(lcFacility), " AND jomast.fac = '" + lcFacility + "' ","") + ;
			IIF(TYPE('lcRevision') <> 'L' AND NOT EMPTY(lcRevision), " AND jomast.fpartrev = '" + lcRevision + "' ","") + ;
			" ORDER BY " + ALLTRIM(lcSortOrder) 

	IF SQLEXEC(lnHandle,lcSql,"rpjoss") < 0
		IF USED('rpjoss')
			SELECT rpjoss
			USE
		ENDIF
		RETURN .F.
	ENDIF

**	11/13/2002	WCY
**	CR 100825
**	This function is no longer used
**	Step 2: create and populate a second cursor from the VFP functions
*!*		CREATE CURSOR rptmp2 ;
*!*			(fjobno c(LEN(rptmp1.fjobno)), ;
*!*			opercom c(4), ;
*!*			operwrk c(LEN(jodrtg.fpro_id)))
*!*
*!*		SELECT rptmp1
*!*		GO TOP
*!*		SCAN
*!*			INSERT INTO rptmp2 ;
*!*				(fjobno, opercom, operwrk) ;
*!*			VALUES ;
*!*				(rptmp1.fjobno, ;
*!*				OPERCOMP(upper(jomast.fjobno)), ;
*!*				OPERWORK(upper(jomast.fjobno)))
*!*		ENDSCAN

*!*		CREATE CURSOR rptmp2 ;
*!*			(fjobno c(LEN(rptmp1.fjobno)), ;
*!*			operwrk c(LEN(jodrtg.fpro_id)))
*!*
*!*		SELECT rptmp1
*!*		GO TOP
*!*		SCAN
*!*			INSERT INTO rptmp2 ;
*!*				(fjobno, operwrk) ;
*!*			VALUES ;
*!*				(rptmp1.fjobno, ;
*!*				OPERWORK(upper(rptmp1.fjobno)))
*!*		ENDSCAN

**	Step 3: combine the two cursors
**	lcSortOrder2 = STRTRAN(lcSortOrder, "JOMAST.", "rptmp1.")

*!*		SELECT	sortitem, fdescript, fstatus, rptmp1.fjobno, fsono, fac, fpartno, fpartrev, fcudrev, fcdisprev, ;
*!*				fjob_name, fquantity, acthours, rptmp2.opercom, rptmp2.operwrk, fddue_date, fact_rel, ;
*!*				fopen_dt, factschdfn, factschdst, frouting, fdfnshdate, fstrt_date ;
*!*		FROM rptmp1, rptmp2 ;
*!*		WHERE rptmp2.fjobno = rptmp1.fjobno ;
*!*		ORDER BY &lcSortOrder2. ;
*!*		INTO CURSOR rpjoss

*!*		SELECT	sortitem, fdescript, fstatus, rptmp1.fjobno, fsono, fac, fpartno, fpartrev, fcudrev, fcdisprev, ;
*!*				fjob_name, fquantity, acthours, fcopencomp as opercom, fcopenwork as operwrk, fddue_date, fact_rel, ;
*!*				fopen_dt, factschdfn, factschdst, frouting, fdfnshdate, fstrt_date ;
*!*		FROM rptmp1 ;
*!*		ORDER BY &lcSortOrder2. ;
*!*		INTO CURSOR rpjoss

ENDIF

RETURN

**************************************
**	Report Functions and Procedures	**
**************************************
**	11/13/2002	WCY
**	CR 100825
**	This function is no longer used
*!*	PROCEDURE OPERCOMP
*!*		Parameter dvar
*!*		Opqty=0
*!*		Compqty=0
*!*		dvar2 = substr(dvar,1,10)
*!*		select jodrtg
*!*		M2MSeek(dvar2, 'jodrtg','jobnoop',.F.)
*!*		* If no record, return 0 % else go up 1 record
*!*		* deb - cr #68872
*!*		lncount = 0
*!*	    Do while dvar2=Jodrtg.fjobno
*!*			if M2Meof()
*!*				exit
*!*			else
*!*				* deb - cr #68872
*!*				Opqty=Opqty+Jodrtg.fnpct_comp
*!*				lncount = lncount + 1
*!*	*!*				Opqty=Opqty+Jodrtg.foperqty
*!*	*!*				Compqty=Compqty+Jodrtg.fnqty_comp
*!*				M2MSkip()
*!*			endif
*!*	    Enddo
*!*		* deb - cr #68872
*!*	*!*	    result=str((Compqty/Opqty * 100))+'|'
*!*	    result=IIF(lnCount <> 0, str(ROUND(opqty/lncount,0),3)+'|', '000|')
*!*	return result

**	11/13/2002	WCY
**	CR 100825
**	This function is no longer used
*!*	*SJM 8/17/98 CR43396
*!*	PROCEDURE OPERWORK	&& Find the operation currently working in.
*!*		Parameter lnJob
*!*		private lcCurrOper, lnCurrOpNo
*!*		lcCurrOper='      '
*!*		lnCurrOpNo=0
*!*		select jodrtg
*!*		M2MSeek(lnJob, 'jodrtg', 'jobnoop',.F.)
*!*		do while lnJob=Jodrtg.fjobno
*!*			if M2Meof()
*!*				exit
*!*			else
*!*				if jodrtg.foperno > lnCurrOpNo and jodrtg.fnpct_comp <> 0
*!*						lcCurrOper=Jodrtg.fpro_id
*!*						lnCurrOpNo=jodrtg.foperno
*!*				endif
*!*				M2MSkip()
*!*			endif
*!*		enddo
*!*	RETURN lcCurrOper

*!*		

Which code is current and which is useless clutter? Hard to tell, huh? To be fair, it’s easier when you use the Visual FoxPro editor, because its comments are a different color.

Now, some comments are most certainly worthwhile to explain why the VFP program is written a certain way, but the rest of it is just useless bloat and clutter. I myself comment out large blocks of code when refactoring; however, I remove them before I put that code into production. I realize that M2M needs to keep this documentation so they know how their reports change over time, but why does the customer need to see it?

What do you folks think?

3 comments to We Have No Comment at This Time

  • Scott

    I think there are two possible reasons why they don’t remove it for the customer.

    1. It would take a little time and effort.

    2. The code would be easier to understand making customers less likely to pay M2M for customizations.

    It would be nice if one or more customers/users would go through all the programs, clean them up and then distrubute the code to the customer base. But that would take a lot of time and it really should be M2M’s job, not ambitious customers. Not being much of a VFP programer, I would really appreciate it if there were a lot more comments explaining what the code was doing and why.

  • roleki

    I dunno, I kind of like the fact that the old code is still hanging about. For one, if you’re reverse-engineering M2M reports, it shows you at least one approach that DOESN’T work. Secondly, sometimes it sheds light on how a particular prg became so twisted. Lastly, every so often you’ll run across a comment like “I have no idea what this does” and that lets you know you’re not the only one.

  • Jason Griffith

    Yeah, typically if I’m going to comment out a block of code, it’s because the thing is useless. Extra code doesn’t really need to be commented out in most cases.

    I’m a bit of an obsessive commenter in my own code, I not what my variables are used for, what this block of code does, the point of it being there, and anything I intend to add/edit in the future.

    When I remove a block of code, I put in a comment to explain what I used to do, and why I made the change, along with the date. If it’s something I may consider going back to later, then I’ll have a backup copy saved somewhere that will have that code if I should have need to access it at a later date. If I removed the code because it didn’t work or was way more effort that actually required (like I found an easier, more effective method) then I may or may not have a backup copy of it lying around, but that will be noted in the comments as well.

    Solid comments can make your code go a long way towards helping other programmers understand your code, and it helps you out too if you come back to a report after several months/years and have to remember what in the world you were doing. I’m not a VFP programmer either, so a lot of this stuff is beyond Greek to me, save for where it shares similar syntax with VB.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>