Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Challenge Yourself Expand / Collapse
Author
Message
Posted Monday, August 6, 2007 7:55 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, May 16, 2013 3:56 PM
Points: 280, Visits: 140
Naw, I think in SQL just fine. Steve mentioned business rules and that is another good thing to comment, but that's part of documentation, not explanation of the code. It's pretty important to document why you did something especially if you did it in an unorthodox way.
Post #388357
Posted Tuesday, August 7, 2007 9:49 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 12:38 AM
Points: 33,267, Visits: 15,436
But only if it's not obvious. Don't want to read comments about "used a left join because we have missing rows"

Use something like "some orders don't have a shipper, so left joined with Shippers table"







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #388630
Posted Tuesday, August 7, 2007 4:59 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, September 20, 2007 10:10 PM
Points: 22, Visits: 1

I suppose in comment on the reason for this post is to 'Challenge Yourself'.  Not only in those things we thought we knew, as software changes and evolves, maybe some idioms are no longer valid.  I've been using SQL Server since Sybase was sucked up into the MS stable and there are still more things to learn (Thankfully !).   I thought that I knew dates but Itzik Ben-Gan's articles on Datetime calculation were a cool breeze throught the dusty portions of my briefcase.   So I suppose the challange is being open and prepared to be challanged.   and for those wondering ....

Last Monday (inclusive)
SELECT DATEADD(day, DATEDIFF
(day, 0, -- Base Monday date
GETDATE()) /7*7, 0); -- Base Monday date.

Pure genius....

CodeOn

Post #388761
Posted Friday, August 10, 2007 5:15 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, August 1, 2014 4:13 AM
Points: 67, Visits: 715
I've always thought that comments were a description of what you intended the code to do. You don't get this info by reading the code - you just get what the code actually does.




There is no problem so great that it can not be solved by caffeine and chocolate.
Post #389584
Posted Friday, August 10, 2007 7:24 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 12:38 AM
Points: 33,267, Visits: 15,436
Hopefully they're the same thing

I think that most comments are what you intend the code to do, but not explaining what a knowledgable person should be able to decipher. There should only be comments on something that's not obvious.

Or I sometimes make comments on a change in behavior as a reminder to myself or someone that comes along later.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #389630
Posted Friday, August 10, 2007 8:00 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, August 1, 2014 4:13 AM
Points: 67, Visits: 715
Yep, the comments should be fairly a high-level description of the coder's intent.

If the two don't match then the reviewer has to ask questions...


There is no problem so great that it can not be solved by caffeine and chocolate.
Post #389667
Posted Monday, October 1, 2012 12:12 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, September 1, 2014 5:24 PM
Points: 2,047, Visits: 866
In longer procs/scripts I'll add "section breaks", sort of very high-level pseudo-code, to help me quickly identify what a section of code does (or is meant to do). I find that really helpful if/when I have to revisit something months after I last looked at it.
Post #1366325
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse