Re: Document A Project
- Posted by Greg Haberek <ghaberek at gmail.com> Feb 18, 2005
- 532 views
> How would you document a project, such as you were making a game in Euphoria, > how would you document it something like this: > #include necssary files > #clear screen What helps me in bigger programs is to explain what each routine does right after I declare it, then follow that logic with little comments. That's pretty much how all my code ever looks. Although for distribution, I have a little utility that strips any comments starting on the first line, which helps reduce the size of my files. (Sometimes over 1/2 my code is comments, heck look at Win32Lib, it's nuthin but comments!) Example: (I'm using this in an app I'm writing)
global function dayOfWeek( integer pMonth, integer pDay, integer pYear ) -- This function determines the day of the week given -- a date in the form Month, Day, Year. I believe this -- formula may be more accurate than Junko's, or I'd -- be using Junko's instead. :) -- -- Step 1: Take the last two digits of the year and add 1/4. -- Step 2: Determine month code. -- Step 3: Add year, month code and day -- Step 4: Take remainder of seven. -- -- The result is the day of the week (starting with Monday) integer lCode, lResult -- subtract 100 until pYear is less than 100 while pYear > 100 do pYear -= 100 end while -- add 1/4 to the year pYear += floor( pYear / 4 ) -- determine month code, MONTH_CODE -- is declared else where in our code lCode = MONTH_CODE[ pMonth ] -- add the values lResult = pYear + lCode + pDay -- get remainder of seven and add 1 lResult = remainder( lResult, 7 ) + 1 return lResult end function
~Greg