DEV Community

Cover image for Code with Sherlock, how the Science of Deduction helps to write better code.
Giovanni Mazzuoccolo
Giovanni Mazzuoccolo

Posted on

Code with Sherlock, how the Science of Deduction helps to write better code.

I'm currently reading "How to Think Like Sherlock: Improve Your Powers of Observation, Memory, and Deduction" by Daniel Smith. This interesting book explores the way Sherlock Holmes thinks and solves problems, and I've noticed many similarities between his methods and the daily life of a software developer.

So, let's wear our deerstalker (Sherlock's famous hat), and dive in!

1. The crime scene: Analysing Requirements

This is the part when Sherlock is scrutinizing a crime scene, trying to gather as much information as possible. Whenever we start a new task, a new project, or someone assigns an issue to us, the more information we collect, the more refined our work can be.

What can we learn?

  • Sometimes, Sherlock asks some basic questions to ensure everyone is on the same page (and, yes, to show off a little, but I am not suggesting you do that :) ). Before starting, any question is welcomed, even the most seemingly simple one. We can always introduce our question with phrases like: "Just for clarification" or "I have a simple question, ..."

  • Anything that is unclear needs to be made clear. If something is unclear, this is the best time to make it super clear! This includes deadlines, intermediate deliveries (milestones), requirements, and even the non-happy path scenarios. Think of it as a poker game with cards on the table."

2. Studying the enemy: Observing patterns

As Sherlock would observe and notice subtle details, we can benefit from recognizing patterns in the codebase. By understanding recurring design patterns or identifying common issues in the code, you can improve code quality and maintainability.

What can we learn?

  • By observing patterns, we can better understand our codebase, applying software principles like DRY (Don't Repeat Yourself) to identify pitfalls and potential future problems.

A software developer study in scarlet

3. "Deduct" the bug to solve it.

When encountering bugs or issues in your code, a deductive mindset can be valuable in the debugging process. Analyze the symptoms, consider potential causes, and systematically narrow down the possibilities until you find the root cause.

What can we learn?

  • Understanding the bug before solving it is essential. Using Stack Overflow is helpful, with the caveat of understanding what we are copying and pasting rather than blindly relying on it. Sherlock would never do that.

4. Learning and Improving:

Just like Sherlock was a continuous learner, you should always seek to improve your coding skills. Dedicate time to learn new technologies, programming languages, and best practices, and apply them to your projects.

What can we learn?

  • Don't be scared of the unknown; big minds work with curiosity.

  • If you are spending too much on courses, it's wise to buy a new one only after completing the previous one.

5. The Dynamic Duo: Collaborating with Other Coders

Holmes and Watson were an unbeatable duo, and so shall you be with us coders! Apply deduction in collaboration, respecting others' perspectives while collectively deducing solutions. The synergy of minds shall birth innovative marvels that transcend the sum of their parts.

What can we learn?

  • "Do not be scared to delegate. This is very difficult for me. I am often worried about relying on others and getting poor results. But coding is a marathon, and helping each other is the best way to reach the common goal.

  • If you see that you are going to miss the deadline, telling before is better than informing after you miss it.
    Proactive communication is vital in software development because it allows for better planning, resource allocation, and risk management. If you wait until after the deadline has passed to inform others about the delay, it can lead to disruptions, missed opportunities, and a loss of trust from stakeholders.

Do you find any other common things about the Science of Deduction and Software development? Let me know in the comments!

P.S. Check out my side project: Dutch for developers where you can learn Dutch and land a job in The Netherlands!

Top comments (0)