2 best tools that can help you solve ANY software development problem

Introduction

You read it correctly. Any is a very broad term. However, these two tools that I’m going to talk about in this article allow me to solve any software development problem across a very broad range of skills.

The problem

Let’s first start with a very nice problem. As already explained in this post, some database systems (e.g. MySQL, SQL Server) allow you to acquire physical predicate locks on range scans so that no other transaction can modify the locked range.

MySQL

Let’s give it a try on MySQL, and see if the predicate lock blocks an insert in the same range of rows:

Since we locked all employee rows for the department_id with a value of 1, Bob’s INSERT statement is going to be blocked waiting for Alice to release the lock, which she does at the end of her currently running transaction.

However, if we try to add a new employee record in the department number 3, we can do it since the predicate lock only affects the employee(s) belonging to the first department:

So far, so good!

SQL Server

Let’s see what happens when we switch to SQL Server. The first example works just as expected. However, the second use case yields the following outcome:

Why is Bob’s INSERT block since there is no overlapping between the locked departement_id = 1 range and the departement_id = 3 which is used by the incoming INSERT statement?

How do you figure it out, right? You start reading SQL Server documentation hoping to find the right answer, but whata if you still can’t understand why SQL Server behaves like this in this particular scenario?

Finding the solution

Every time I run into a problem like this one, I use the first best developer tool: StackOverflow.

StackOverflow

Many developers rely on StackOverflow to find the answer to a problem, but what if no one asked the same question as yours? Unfortunately, few developers I know turn to StackOverflow whenever they have a good question to ask.

StackOverflow is a two-way street. If you are an avid StackOverflow consumer, you need to pay back as well. I like to give answers on the topics that I know best, but it’s impossible to know everything! Therefore, why not ask the pool of thousands of passionate developers whenever I bump into a very interesting issue?

That’s what I did, and here you can find my StackOverflow question.

In less than 30 minutes, I already got two very good answers which explain why SQL Server behaved as it did.

This time, I got lucky. But what if no one answers your question? Then, you should add a bounty to it and see if that helps.

Right after asking the question on StackOverflow, I like to turn to the second best tool for solving any software development problem: Twitter.

Twitter

Twitter is awesome! It allows you to get in touch with so many great people that share the same passion for software as you do.

So, I also asked the question on Twitter, and guess who replied back?

The official account of SQL Server validated that both answers are correct. How cool is that!

Most software companies hire Developer Advocates that monitor the official twitter accounts and try to help you get the most out of their products. So, take advantage of this opportunity whenever you have a good question that is not easily solvable.

If you enjoyed this article, I bet you are going to love my book as well.

Conclusion

The 2 best tools for solving ANY software developer problems are social tools, and that shouldn’t come as a surprise. We are all social beings, and we have evolved to rely on each other whenever we have a problem.

So, don’t hesitate to ask for help! It’s as simple as that.

Enter your email address to follow this blog and receive notifications of new posts by email.

Advertisements

2 thoughts on “2 best tools that can help you solve ANY software development problem

  1. Hello Vlad!
    Why did MySQL behaved different than MsSQL? From Damien’s response MsSQL needed a index, but how come MySQL didn’t need that index. Will Oracle behave any different?
    Thank you

    1. That’s a very good question. Well, MySQL automatically creates indexes for all Foreign Keys, and, unlike SQL Server, there is no such thing as lock escalation in MySQL, Oracle or PostgreSQL.

      However, there is one use case where MySQL behaves like so. Check out this StackOverflow question.

      As for Oracle and PostgreSQL, they don’t support physical predicate locks that guard the gap between entries. You’d need to lock the whole table to get the same behavior, but that would not be very practical.

      However, you can use optimistic concurrency control to detect when a change like that happened. Check out this article if you’re interested in this topic.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s