Author: way0utwest

  • Better Comments

    I assume most of your comment your code.

    Well, you probably comment code most of the time.

    I’d bet your comments have quite a bit of detail.

    And you do this completely inconsistently.

    That’s what I’d think, or maybe just what I want. Even the best developers I know will not consistently comment code. You can drift through any project on Github and see this. Those projects on GitHub might even be better documented because people know they are public. In most corporate environments I have worked in, I’ll find that when people get busy, or distracted, or even when they’re experimenting to find a solution, and they don’t write detailed comments. Usually only when someone fixes a bug, with a solution found quickly, do I get a really useful comment.

    There are all sorts of ways that people think about commenting their code. I ran across a post from Annette Allen about adding comments. She noted that she has headers in her stored procedures and other comments. However, after a few months, she wasn’t sure that the comments actually helped her. I’ve had that same feeling at times when looking back at comments, both mine and others.

    Do you have a method for choosing the words you use to comment code? Jeff Atwood says to comment on why you did something, not what. I’ve seen that before, especially with version control commit comments. We often can look at code to determine what it does, and if you use a VCS extensively, then you can always see the changes that were made between versions. The comments typically give me some rationale for the work I did. Over time, I find that if I think about how I’d explain my reasoning to myself in the future, I come up with a good comment.

    You might feel differently, and if so, please let me know. Perhaps there are some good ideas you have about choosing comments, and perhaps you have examples. Some might include a bug or Jira number, which I like, but others may hate. These could be comments inline in code or those you use when comimtting to a VCS.

    Share some thoughts today, and if you have any entries for the best code comment, drop them here.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 3.1MB) podcast or subscribe to the feed at iTunes and Libsyn.

  • Project Euler

    I like having problems to practice solving in computer science. It can be a fun hobby, and it exercises your mind. I have enjoyed the Advent of Code, though some of those are complex and hard to focus on in my busy life.

    My middle son asked about Project Euler as he finished his first year of college and suggested we try some together. He’s been busy, though I have called him down as I’ve solved one or two. He’s asked I send him my code, which I’m doing in Python as practice. He’s using C++, which is something he’s studying, but he knows some Python.

    These are all math based problems, and most are short in the archives. I’ve been trying to take 5-10 minutes and solve 1 a day. I’ll ping my kid when I’m working, and we might pair program a bit to get a solution.

    Not terribly challenging, but it is a different type of thinking from most data work, and it can be fun. If you want to take a break from other work, maybe experiment with a new language, give Project Euler a try.

  • No @@ServerName on Linux

    I setup a new instance of SQL Server on Linux some time ago. At the time, the Linux machine didn’t have any Samba running, and no real “name” on the network. As a result, after installing SQL Server I got a NULL when running SELECT @@SERVERNAME.

    The fix is easy. It’s what you’d do if you had the wrong name. You run:

    sp_addserver ‘Ubuntu’, Local

    In this case, Ubuntu was the name I gave my machine under the Samba server, since that’s the OS. I don’t plan on adding more for now, so this is fine.

    After the chance, I couldn’t restart the instance from SSMS, so on the host itself, I ran a

    sudo systemctl stop mssql-server
    sudo systemctl start mssql-server

    That completed, and my @@servername is now working.

  • Get What You Pay For?

    Many items that we choose to buy have some relation between the price and the quality of the item. We often find that a more expensive appliance or automobile has better quality than a cheaper one. There’s certainly a point at which spending more doesn’t necessarily get you better quality or even value. This seems especially true today with many “over the top” products that have added features or design that don’t seem to be worth the additional cost. At the other end, there are times many of us pay less for less quality, consciously making that tradeoff. I also think that the base level of quality has risen for so many products that it might not be worth spending more than some amount for an item. They’re all close in value and performance.

    I ran across a piece that looks at the value of consumer and enterprise SSDs. This isn’t a scientific analysis, but rather a short discussion of why enterprise SSDs might be more than twice as expensive as consumer ones. There are some details, such as the architecture and spare capacity, but ultimately the author notes that people purchasing drives also worry about the perception that they might have saved money with a cheaper drive, but lost data because the warranty and support are lower. Even if the same hardware were being sold by the vendor, which I’m sure happens, having enterprise support is a crutch that can provide the employee some protection if there are issues.

    There certainly are hardware differences for most devices, though the buyer should beware and verify that they are actually buying enterprise level gear. The big difference for me is that the large over provisioning of enterprise devices offers more predictable performance sustained over longer periods of time. This is important, especially for databases that might get quite a bit of transaction log or tempdb activity. In those cases, we need sustained high rates of I/O.

    There are no shortage of white papers, articles, reviews, and vendor claims about their particular hardware. This is a very competitive and also highly profitably space. If you’ve had to purchase a new SAN device at any point, you know these are expensive and complex. Making the decision is stressful as it can take lots of time ot evalute, lots of resources to get things installed, and so it’s not easy to go back on the purchase. In addition, many of us that have to make a recommendation are usually asking management to spend 6 or 7 figures on a device. If it doesn’t perform, we will take the blame and may find our choice to be career limiting.

    I don’t envy anyone that needs to make hardware decisions for their database or organization. There are so many companies in the storage space now that it’s a large project just to evaluate the various products and try to make a decision. It’s complex enough these days that I can see why moving to the cloud is attractive for some. While we can’t control everything and we may have large monthly bills, we typically don’t ever have to face that extremely large capital purchase decision.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 4.5MB) podcast or subscribe to the feed at iTunes and Libsyn.