-
Notifications
You must be signed in to change notification settings - Fork 1
Conventions
It kinda works. I try to have at least one test per function. That's always the first goal. Eventually get IntelliTest working.
Those XML blocks are a bit bloated. I'm waiting for the JSON version of XML java-doc.
So "C" on the end of functions that take a character or string of characters as inputs. Just enough information for me as the regular user to distinguish between similar functions between ones that deal with characters and treat strings as character arrays, ones that deal with strings, and ones that deal with matches. I might add "I" for ones that deal with integers, since SQLCLR doesn't support type overloading.
Not always, but when it makes sense. IsNull, for instance. StringExtract functions don't follow this, since it would always be "Get-" or "Extract-". Repetitive, and leaving the verb off makes it more like command English. You might say "There!" instead of "You, sit there".
I wanted to see all the string classes together. So StringExtract, StringTest, StringReduce, etc.
I created an IsEmpty and IsNull and IsNullOrWhiteSpace, etc, since I see these things as documentational, rather than "string.Length != 0" or "string != null".
So if you ask a function "How many characters are in a null string", it returns null, rather than 0. The rules of SQL are null inputs are null outputs. However, I do not follow this for search strings (markers.) If you ask, "How many nulls in the string 'ABCD'", I throw an exception.
Throw early, debug early, rather than (you know who) avoid or discard exception cases so the downstream developer gets stuck dealing with it.
I used to ignore the message pane in VS Error List. But it is very educational, and results in cleaner code. The biggest issue in debugging is with the brain's insistence on processing all input when reading. You could skim, but then you would miss the bug you're looking for. So your brain gets hung over and over when reading down a document, like "string.ToString()." Not an error, but a squiggly, and a trip-up when scanning. The more you take out, the more your brain can automate and slip down to real errors. Also why I say "name.IsNotNull()" rather than "name != null).
Not consistently, but at least I try to have "input", "marker", "pattern", and "sep". One great benefit is that cut and paste validation code can be copied down. input can be null and return null. marker can never be null, or pattern. marker can be non-empty whitespace but pattern cannot. "sep" is a bit of an awkwardness since it is pretty much a marker, too. Hmmmm. Note that SQLCLR functions on the SQL side do not care one iota about the function's argument names, just types.
git, github, free
I hate reading history in github and every file has the same comment on it.
Look before committing! This gives you an "oh yeah" moment.
And document them better. For some things like typos, then "typo" or "spelling" is fine.
I can't remember how I would call such and such function.
Pushes the boundaries, so don't expect code that doesn't do something risky. Read the code before using. I use it in DBA work, but for actual production I would have to think very carefully. Perhaps that would be a subset.
At least for some things.
I know probably no one is using it, but for local databases running DBA scripts against remote servers, this is really reliable.
Heavily! I don't care about performance affect. Maintenance cost is a bigger deal than performance cost!