Author: way0utwest

  • Daily Coping 13 Jan 2022

    I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag.

    Today’s tip is to take 5 minutes to sit still and just breathe.

    This is a hard one for me. You’d think it was easy to just take a break and stop working, but I have lots to work on, and I feel like I could tackle something else. I usually reserve breaks for the gym, so just sitting here is hard. I get antsy.

    If I was taking a 5 minute break, I’d want to hang on the inversion table and just think. At least then I’d be gett

    I know I need a break, especially when I’m busy. Easy to get caught sitting at a desk too long in this business. I decided to give this a try and pick a time that works for me. Since my schedule varies a lot, depending on work meetings or life, I didn’t want a specified time on my calendar. Instead, I decided to try this each time I get up for coffee. Set a timer, roll my chair to the window and sit and breathe.

    It was quite hard the first time or two, but got a little easier. I’m giving this a week to see how it goes.

  • A Little Current Date Arithmetic in Powershell–#SQLNewBlogger

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

    I saw a fun post on Twitter recently asking days until retirement. I wrote this code:

    DECLARE @YearsToRetire INT = 11;
    SELECT DATEDIFF (DAY, GETDATE (), (DATEADD (YEAR, @YearsToRetire, GETDATE ())));

    I thought that wasn’t bad, but then I wondered, how would I do this in PowerShell? I knew there had to be a way, so I googled and ran into this article. That showed me Get-Date and the AddYears() method. So I tried this:

    2022-01-05 10_26_03-C__Users_Steve

    That didn’t work well. I ended up storing the date in a variable and then things worked. However, I was bothered. I can pipe and combine things, why didn’t this work?

    Then I thought about something. I ought to enclose the Get-Date inside something. I tried parens, like this:

    (Get-Date).AddYears(11)

    That worked great. As I get more familiar with PoSh, I can figure more things out myself, and quicker.

    2022-01-05 10_28_06-C__Users_Steve

    SQLNewBlogger

    Once I figured out the way to do this, I spent about 5 minutes on this post. Actually 6 minutes with this part added.

    I took something I figure out and wrote this up quickly. I even added a great line at the end, that I figured it out and my work with the language is paying dividends.

    A great little type of post that would highlight your blog.

  • Coding for the Future

    I posted a note on Twitter about some code. In this case, it was the start of a for loop, but with two things in it that I didn’t like. The code is shown here:

    for ($i = 2011; $i <= 2021; $i++) {

    Both the starting point and the ending condition were problematic for me. This code is used in a scheduling application, to populate a dropdown that I used regularly. It’s always worked, since about 2017 or 2018, and I had no reason to even think about the algorithm. I assumed the code was something like this:

    for ($i = 2011; $i <= year(); $i++) {

    In fact, when I had issues on 27 Dec, I assumed that things were coded to the current year and I’d be able to schedule things on Sunday night when I got home. Instead, things still didn’t work the first few days of 2022 and I had to get someone to come in from holiday to fix the code. Now it looks back a few years (likely unnecessary) and looks forward one year, as it should.

    I don’t know why a developer would bother coding anything like this. Get the need to perhaps test something expediently and limit choices, but hard-coding most anything is a poor idea. There ought to be some logic in how or why you choose values, and that logic often can be expressed in code that adapts to situations. I certainly could have lived with only the current year being available, though that still doesn’t think through the problem space well.

    I’ve seen lots of simple bugs in code over the years that are similar to this one. These often occur because the developers haven’t thought through how code might need to adapt to slightly changing situations. Something like a change in the year, or maybe the addition of a time slot for scheduling or a new location added, even a new tax rate. Often I find developers think they have considered the problem given to them, but a little too tightly. They haven’t thought about how their code might change if the user requesting the feature has made a mistake.

    Writing code that solves a problem and allows for adaptation to likely scenarios is a bit of an art. It can be hard to do, but great developers assume users will need some changes and plan for this in their solution. They also assume users make mistakes in their specifications and they don’t hard code anything.

    Steve Jones

     

    Listen to the podcast at Libsyn, Stitcher, Spotify, or iTunes.

  • Daily Coping 12 Jan 2022

    I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag.

    Today’s tip is to write a short list of 3 things you feel grateful for and why.

    My list:

    • Health
    • Finances
    • Kids

    Not the top list, and certainly I am grateful for my wife and my own kids, but these are additional items.

    Health

    I’ve been relatively healthy for most of my life. While I have bad knees and ankles, some joint issues, most of these are minor and impede my ability to be athletic, but don’t prevent it. I’ve rarely been sick. I’ve had COVID and I had the flu one other time. I get colds every 2-3 years, but for the most part, I don’t have any chronic issues.

    I got some worrisome numbers at my last checkup. Nothing too bad, but for someone that mostly gets a clean bill of health, I need to change a few things as I age. I’m “pre” a few things, so I’m working to get better, but that has helped me appreciate how blessed I am, even as I need to pay more attention.

    Finances

    I’ve had a good career, with jobs that paid well. Nothing amazing, but I have been well compensated for most of the last 30 years. I also built and sold a business, which didn’t let me retire, but it made life comfortable for my wife and me. My wife also had a great job and provided more support for the family than I did for a long time.

    We’ve invested in real estate, had good success, saved some money from corporate 401k plans, and we are in a great position. While we aren’t able to retire in our 50s, and college for kids is a bit of a strain, we are in a better position than most people in the world, and I’m grateful for the security and peace of mind that brings.

    Kids

    I have three adult kids, and I enjoyed watching them grow up. I enjoyed being a part of their activities, their successes, and their struggles. I am very proud of where they are in the world.

    However, I miss the time I used to get with kids, watching them learn and grow. Fortunately, I have become a decent volleyball coach and can spend my hobby time there. My wife and I have spent the last 3 years together running teams of kids during the winter and spring, competing at a fairly high level.

    As tired as I can get and as stressful as some events can be, I love spending 6 months with a group of kids, watching them learn, grow, struggle, and succeed. I take a lot of pleasure in seeing them later as they continue to grow and develop.

    I’m grateful that these kids are a part of my life.