Checking my work

  • Occationally, my boss will ask me to do a data query. Sometimes I am so pleased with myself that I did it so quickly that I just fire the data off to him without checking. I absolutely know there is no excuse for this. No one else in the office works with the data, so I don't have a co-worker who can check the work before sending it to the boss.

    My question is: Does anybody have a good routine set up for checking their work? I need to have a plan and implement it each and every time so I don't develop a reputation for needing to be second-guessed (if that hasn't happened already).

    Thank you in advance,

    Amy

  • Amy,

    In my humble opinion this is almost the hardest thing to tackle. At least in the environment you've described. If there is no one to smoke test your approach or results than you are left to your own devices. It's never a good idea for the same person to code and subsequently test that code. You'll inevitably only test for the things that you think of and nothing more.

    Your best bet is to slow down. If you're given verbal requirements, write them down and give them back to the person requesting for approval, or at least read through them several times before coding.

    One other method I've used, is once you have the request completed. Start over completely and write the code a different way. We all know there's always more than one way to skin a cat in SQL. If you can write the code two times differently and get the same results you should be good.

    Bottom line, make sure you have requirements and push for a test plan or someone to smoke test your work. Otherwise you're just going to have to review review review.. 🙂

    Hope this helps.

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • I do a common-sense check on the data before I send it, but it's just an eyeball-it-quick thing.

    Most of the time, I can safely assume the person consuming the data knows more about the data definitions than I do, and can more efficiently, accurately, and effectively check it than I can. I make it clear to people who are requesting ad hoc queries that that's my operating basis, and very few have ever objected to that. I just make sure that the wording is, "You are more expert on the expected values of the data than I am, so I am trusting you to know more about what it means", rather than, "I'm too lazy to do my job correctly, and am dumping this on you because your request is a waste of my minesweeper time". (Okay, I'm exaggerating for humor. But I'm sure you get the idea.)

    Your job as DBA generally doesn't involve expertise in the actual data content. It's about structure, coding, et al, not about knowing "hey, that account balance looks low for that time period, are we accidentally excluding rows because of a poorly worded Where clause?"

    If I'm not sure about the business translation of the query, I get the person who'll consume the data to come to my desk while I'm writing the query, and go over the aspects and options of the Join predicates and Where clause with them. Anyone who objects to doing that gets a "your mileage may vary" warning on the query results. Almost nobody ever does object though. Not if you make it clear you want the help so that you can use their expertise to make sure the query is done right the first time. Most people will be perfectly willing to help you help them.

    Or am I misreading your question completely?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thank you for the suggestions. Now the goal is to actually implement them. Sounds so easy... 🙂

  • It's like any habit.

    Start doing it.

    Remind yourself any time you catch yourself not doing it.

    Soon you'll be doing it pretty automatically.

    It takes work to remember at first, and then gets easier as you groove in the habit.

    You could do the same if you wanted to start chewing your fingernails, but I really can't reccomend that particular habit. :w00t:

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Good suggestions above. One thing I do it evolve my process over time. It's hard with ad hoc queries, but I will find that someone will ask for data, but they'll mean "no zero sales" or aggregate the quarters, or some other type of check that I can apply to future asks.

    It's not perfect, but having a few things your boss is looking for can help you double check your work again.

  • Amy.G (11/2/2011)


    Occationally, my boss will ask me to do a data query. Sometimes I am so pleased with myself that I did it so quickly that I just fire the data off to him without checking. I absolutely know there is no excuse for this. No one else in the office works with the data, so I don't have a co-worker who can check the work before sending it to the boss.

    My question is: Does anybody have a good routine set up for checking their work? I need to have a plan and implement it each and every time so I don't develop a reputation for needing to be second-guessed (if that hasn't happened already).

    Thank you in advance,

    Amy

    I'll start off by saying I'm a developer, not a DBA, so my methodology may not apply.

    When I have a task to do, I start with pen and paper and jot down a few algorithms. Normally, I end up with between 3 and 10 algorithms written down. I'll then code up the 3 that I think are most likely to perform the best, as well as 1 RBAR algorithm. Once these have all been done, I set-up a test environment based on the table structures and data set and run them all against it comparing the result-sets by inserting each one into temp tables.

    Assuming that they all produce the same results, I then run the two fastest against a sub-set of the actual data and again compare the result sets by inserting into temp tables.

    Assuming we're still good, I then do a final logic check of the fastest algorithm, then submit the code into the correct branch of our software and write a note to QA explaining that it's ready.

    So far, I've never had a query come back to me from QA due to incorrect or inconsistent results.


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply