Posted in T-SQL, T-SQL Tuesday

T-SQL Tuesday #164 – All the Feelings

Happy T-SQL Tuesday!

This month is hosted by Erik Darling (t | b). His challenge for us is: to think back to the last time you saw code that made you feel a thing.

One of his rules for this that it can’t be my code. Most of the time, if I’m looking at someone else’s code, it’s usually part of a code review or a pull request. I’m already looking at it critically, trying to find the mistakes. It’s not that I expect them to write bad code, but I’m looking to make sure the code is efficient and doesn’t have any obvious mistakes. The other time I’m looking at someone else’s code, I’m trying to solve a problem.

Erik wants to talk about the last time code made us feel a thing, but I’m having trouble thinking of just one good example. But let me tell you, I’ve looked at a lot of code over the years and I have a lot feelings:

Sad

They’re doing that bad habit. Maybe it’s an inline correlated subquery (SELECT colA, (SELECT from table) as subquery FROM massivetable). Or maybe it’s a simple as using NOLOCK everywhere when it’s not necessary.

I haz extra sad

They’re doing that bad habit because someone told them that it was the standard they had to follow. Is “facepalm” a feeling?

Whaa…????

If it’s not a feeling, it should be. OK, fine, we’ll call this one “confusion”. This is usually how I feel when I look at code and I’m struggling to understand just what exactly it’s trying to. I have a theory that if someone reading your code has problem understanding it, SQL Server does too. I’m usually having to rework the code to either adapt it for another purpose, build upon it, try to solve a problem related to it, or completely rewrite it because of the problems above. But it definitely makes my job a little harder in those cases.

Aarggghhh!!!!!

This is for the code that once I make the proper fixes to solve performance issues or whatever change I need to make, I finally understand what it’s doing and realize that it’s not even useful because the data isn’t remotely close to what we want to see.


Unfortunately, I feel I have a lot more negative emotions to the code that I see that’s not mine. Again, I attribute that more to the fact that I have to be critical because of the reasons why I’m looking at the code. Because I sincerely hope that you don’t walk away thinking that I work with people who don’t know what they’re doing because that’s just not true either. I feel very judge-y sometimes because of it, which is an awkward position to be in.

But there are a couple of other feelings I get looking at code:

Ooh!

Someone solved the problem in a way that I hadn’t expected to see. The code was clever and\or a really simple elegant solution. It’s something I want to keep in mind and borrow the next time I run across that scenario.

Yay!

This is when I see the code of someone who’s learning SQL and has worked really hard to figure out these problems and I finally get to review their pull request. It’s very rewarding seeing someone’s growth and literally give them your “stamp of approval”.


Yep, I run a gamut of feelings when looking at code. I guess you could say that I’m also pretty passionate about it. And I’m going to take that as a good thing.

Thanks again to Erik for hosting. (If you want the full details about T-SQL Tuesday, check out the website.) Looking forward to reading everyone’s posts!

One thought on “T-SQL Tuesday #164 – All the Feelings

Leave a comment