More maintainable code(and others) lessons

My blog has moved.
You can view this post at the following address:
http://www.osherove.com/blog/2003/7/14/more-maintainable-codeand-others-lessons.html
Published Monday, July 14, 2003 9:34 PM by RoyOsherove
Filed under:

Comments

Monday, July 14, 2003 5:34 PM by TrackBack

# HumanCompiler

HumanCompiler
Monday, July 14, 2003 9:21 PM by Duncan

# re: More maintainable code(and others) lessons

I did the database documentation in HTML help - and it was a revalation. You can - for instance - click on a table name in a stored proc and it will take you to the table def, and on each table there are links to the stored procs that use it, triggers, indexes etc.
Am thinking of expanding this to include the VB code that calls the stored procs by integrating with Document!X...(which is such a great product. Pity I haven't got purchase approval for the .NET version yet)
Monday, July 14, 2003 9:23 PM by Roy Osherove

# re: More maintainable code(and others) lessons

SOuds really coo! How did you do it in HTML help? manually? sounds like a difficult task. then again, I did practically the same only in word format...
Monday, July 14, 2003 9:53 PM by Duncan

# re: More maintainable code(and others) lessons

Did it with a quick-and-dirty VB program.
Basically create a HTML file for each table named "TABLE_[tablename].HTM", one for each stored proc "SP_[procname].HTM" and so on.

e.g.
'--------------------------------------------
Public Sub DocumentTable(ByVal Tablename As String)

Dim nFile As Long
nFile = FreeFile

Open "TABLE_" & LCase(Tablename) & ".htm" For Output As nFile

'\\ Print the html header bit
Print #nFile, "<html>"
Print #nFile, "<head>"
Print #nFile, "<TITLE>GOALD Table Def : " & Tablename & " </TITLE>"
Print #nFile, "<META HTTP-EQUIV=" & Quote("Content-Type") & " CONTENT=" & Quote("text/html; charset=windows-1252") & ">"
Print #nFile, "<meta name=" & Quote("GENERATOR") & " content=" & Quote("Notepad and Chardonnay") & ">"
Print #nFile, "<link REL=" & Quote("stylesheet") & " type=" & Quote("text/css") & " href=" & Quote("stylesheet.css") & ">"
Print #nFile, "</head>"
Print #nFile, "<body>"
Print #nFile, "<TABLE id=Header height=100 cellSpacing=0 cellPadding=0 width=" & Quote("100%") & " border=0>"
Print #nFile, " <TR bgcolor=#0b02aa >"
Print #nFile, " <TD>"
Print #nFile, " <P class=" & Quote("titlebar") & ">Table definition: " & Tablename & "</P>"
Print #nFile, " </TD>"
Print #nFile, " </TR>"
Print #nFile, "</TABLE>"
Print #nFile, "<HR>"
Print #nFile, "&nbsp;&nbsp;<a href=" & Quote("tables.htm") & ">All Tables</a>"
Print #nFile, "<HR>"
Print #nFile, "<H1> Fields </H1>"

'\\ Do the fields....
Print #nFile, "<TABLE id=" & Quote("Fields") & " class=" & Quote("sourcecode") & " align=" & Quote("center") & ">"
Print #nFile, " <TR bgcolor=#ccffff >"
Print #nFile, " <TD width=" & Quote("30%") & ">"
Print #nFile, " <P class=" & Quote("comment") & "> Name </P>"
Print #nFile, " </TD>"
Print #nFile, " <TD width=" & Quote("30%") & ">"
Print #nFile, " <P class=" & Quote("comment") & "> Data Type </P>"
Print #nFile, " </TD>"
Print #nFile, " <TD width=" & Quote("30%") & ">"
Print #nFile, " <P class=" & Quote("comment") & "> Size </P>"
Print #nFile, " </TD>"
Print #nFile, " </TR>"

Dim fldThis As rdoColumn
For Each fldThis In gRDOConnection.rdoTables(Tablename).rdoColumns
Call DocumentField(nFile, fldThis)
Next fldThis

Print #nFile, "</TABLE>"

'\\ Close the html text...
Print #nFile, "</body>"
Print #nFile, "<html>"

Close nFile

End Sub
'--------------------------------------------

Then use the MS HTML Help workshop t
Monday, July 14, 2003 11:20 PM by Roy Osherove

# re: More maintainable code(and others) lessons

Which just goes to show - sometimes you just can't beat VB for fast and simple stuff. I love it.