Document Your Code

by Codewiz51 18. April 2013 06:17

I've heard just about every excuse in the world why code is not documented.  The excuses are bogus. All of them.  Documentation must be a part of the corporate culture.  Most organizations do not understand the need for effective code documentation.  There's no training, no policy and no will to make it happen.

Ignoring documentation at the code level, the application level and the infrastructure level leads to another form of technical debt. An organization that ignores documentation, doesn't train personnel to develop it and doesn't incorporate it into their culture is living for today.

This is one of the better articles I've found on the internet regarding the mechanics of .Net program documentation using Sandcastle.  It's long, detailed, and effective.  You should read it.

Tags: , ,

Programming

C++ is a tolerant language

by Codewiz51 14. April 2013 21:18

Every C++ dev knows a java coder.  We're friendly to show we're tolerant. Surprised

Tags: ,

Programming

Passing parameters to and from dynamic queries

by Codewiz51 26. February 2013 19:54

I had a most interesting experience today.  I've been assigned to correct and improve an SQL procedure that was performing poorly during a critical holiday period.

The queries contained in the procedure had been transformed to dynamic queries in order to handle linked servers based on vendor type and geography.  From the start, it was apparent that the original author did not understand how to pass parameters to and from parameterized queries.  Instead, the transformed queries inserted records into a table var for later recovery.

Well, there is an excellent mechanism for passing parameters to dynamic SQL using sp_executesql. A quick check of MDSN presents several excellent examples.  Here's my rendition of the problem.

DECLARE @sqlCommand nvarchar(1000)

DECLARE @campgn1 varchar(20)

declare @startdate datetime

declare @campgnname varchar(50)

SET @campgn1 = 'ABC1234'

SET @sqlCommand =  'SELECT @stdt=startdate, @cname=campaignname FROM ' + @linkserver + '.' + @targetdb + '.dbo.mktcampaign WHERE campaigncode = @campgncode' 

EXECUTE sp_executesql @sqlCommand, N'@campgncode nvarchar(20), @stdt datetime output, @cname varchar(50) OUTPUT' , @campgncode=@campgn11, @stdt=@startdate OUTPUT, @cname=@campgnname OUTPUT

select @startdate as [Start Date], @campgnname as [Campaign Name]

As you can see, it's pretty simple to pass parameters into and out of dynamic sql using sp_executesql.

Tags: , ,

Programming

Resolving problems with JSON2.js on IE 7

by Codewiz51 1. January 2013 07:35

I'm having a problem with JSON on IE 7.  I've followed the recommended fixes: referencing Crockford's JSON2.js, setting type and language attributes, etc.  

I am still getting a 'JSON' is undefined exception on the IE 9 script console when running in IE 7 standards mode.  I am successfully using JSON2.js on the server side in my ASP pages, so this error is just a bit confusing. Based on this post on stackoverflow.com, I am guessing there is some sort of character set/code page issue.  I don't have any of the typo's associated with the post.  I'll have to play around with charset, language and type attributes to see if I can resolve the issue.

I've tested this on my home network, using IIS 7.5 and 8, along with IE 9 running in IE 7 standards mode and it works fine.  This is only happening at work, where I am using IE 9 running in IE 7 standards mode on Windows 7.  The servers are Windows 2003 running IIS 6.  Fiddler doesn't display anything odd that would indicate the script file is not loading correctly, and the charset/code page is 1252, which is normal.

Update:

It seems I need to specify utf-8 in the script file attributes.  This does not appear to be a universal requirement, but it got me past the problem at work where IE 7 verification was not working.  The final script tag is:

<script type="text/javascript" language="javascript" charset="utf-8" src="/script/json2.js"></script>

My guess as to why this fixed my issue? JSON2.js contains unicode character definitions as part of it's regex matching/substitutions code.  Apparently, IE 7 mode on my work computer needed to be told the file contained unicode characters.  Whatever...  At least I'm not chewing cycles trying to fix an arcane issue on a minor and very old browser.

Update 2:

Found one more issue with including json2.js for IE 7.  If you specify your tag as

<script type="application/javascript" language="javascript" src='/js/json2.js'></script>

, then IE 7 will generate an exception when viewing the console.  Make sure you specify your type as type="text/javascript".

Tags: , , ,

Design | Programming

I love this quote. It applies as well today as it did three years ago...

by Codewiz51 31. December 2012 17:53

Unfortunately, this isn't my own thought. It's from a comment to a post by Mike Taylor. It sums up a lot of my own thinking. The details are different, but the thought is pure:

My biggest gripe with modern programming is the sheer volume of arbitrary stuff I need to know. My current project has so far required me to know about Python, Django, Google App Engine and it’s datastore, XHTML, CSS, JQuery, Javascript, JSON, and a clutch of XML schema, APIs and the like. Don’t get me wrong, I’m grateful for all of it, but it just doesn’t seem like what I was promised when I followed SICP for the first time. It just feels like I spend most of my time scouring through documentation and trying to remember umpteen different sets of syntax and class names rather than actually thinking in code.

Tags: , ,

Programming

Disclaimer

This blog represents my personal hobby, observations and views. It does not represent the views of my employer, clients, especially my wife, children, in-laws, clergy, the dog, the cat or my daughter's horse. In fact, I am not even sure it represents my views when I take the time to reread postings.  So, take most of what I say with a grain of salt.

© Copyright 2008-2014