DEV Community

Cover image for Laws of Software Engineering
Aman Shekhar
Aman Shekhar

Posted on

Laws of Software Engineering

I remember the first time I stumbled across the so-called “laws of software engineering.” I was in the middle of a late-night coding session, fueled by too much coffee and an endless string of bugs that felt like they were mocking me. I had been wrestling with a particularly stubborn piece of code for hours when I came across a blog post that introduced me to these laws. Ever wondered why software projects often spiral out of control? Or why seemingly simple features take forever to implement? Yeah, me too.

The laws shed some light on the chaos, and since then, I've been on a mission to decode these principles in my own development journey. Let’s dive in, shall we?

The First Law: Murphy’s Law of Software Engineering

We all know Murphy’s Law: “Anything that can go wrong, will go wrong.” In software development, this law feels particularly relevant. I can’t count how many times I thought I had a simple bug fix in the bag, only to find that I introduced three new issues instead.

I remember working on a React app where I confidently refactored a component. It turned out that one small change led to a cascade of errors across the entire application. What if I told you that thorough testing and code reviews could have saved me a sleepless night? You guessed it; they absolutely could have. So, don’t skip those important steps! The lesson? Always expect the unexpected, and make sure your error handling is as robust as your features.

The Second Law: The Law of Leaky Abstractions

Ever had a moment when an abstraction you relied on just fell apart? The law of leaky abstractions states that “all non-trivial abstractions are leaky.” In plain English, it means that no matter how well you try to hide complexity, it’ll eventually seep through.

For example, I once used a library to handle API requests without diving into how it managed the underlying HTTP calls. When things went sideways, and I had to debug, I realized I was in over my head. I ended up having to learn the intricacies of Axios just to fix what should have been a straightforward error. My recommendation? Get comfortable with the details of the tools you use. It’ll save you time—and sanity—in the long run.

The Third Law: The 90/90 Rule

This one's a classic. The 90/90 Rule states that the first 90% of the project takes 90% of the time, and the last 10% takes the other 90%. I remember a project where I had a prototype up and running, and it felt so good! But then came the polishing—polishing that dragged on for weeks.

Take, for instance, a machine learning project I was involved in. After training a model that performed decently, I thought I was nearly done. But fine-tuning hyperparameters, optimizing data pipelines, and refining user interfaces turned into an endless cycle of iteration. The takeaway here is to allocate resources and time wisely for that last stretch. Don't let it catch you off guard.

The Fourth Law: The Law of Demeter

Also known as the “principle of least knowledge,” the Law of Demeter tells us to minimize coupling between components. In my early days with React, I ignored this law and ended up with tightly coupled components that were a nightmare to debug.

When one component changed, it felt like a domino effect, causing ripples of issues throughout the app. Since then, I’ve learned to embrace composition over inheritance and keep my components as independent as possible. Think of it like a well-organized workspace: the less clutter, the easier it is to find what you need.

The Fifth Law: The Second System Effect

This law suggests that your second major system will usually go overboard because you’ll try to implement everything you learned from the first one. I’ve been guilty of this more times than I can count. After successfully launching a small app, my next idea was to build the “ultimate” version with every feature imaginable.

The result? An over-engineered monster that was slow and unwieldy. What I’ve learned is to keep it simple. Start small with your second system and gradually build. Have you ever tried to do everything at once? It typically leaves you frustrated and your users confused.

Troubleshooting and Lessons Learned

No matter how many laws we follow, bugs will always find a way to creep in. I’ve had my share of challenges, especially with asynchronous behavior in JavaScript. Debugging async functions can feel like chasing shadows, but I’ve found that using tools like Chrome’s DevTools or adding logging can be lifesavers.

Remember, debugging is part of the journey—embrace it as a process rather than an obstacle. When something doesn’t work, try to isolate the issue rather than throwing darts in the dark.

My Personal Takeaways

Reflecting on these laws, I’m genuinely excited about how much they resonate with my experiences in software development. They’ve shaped not just how I code but how I think about building software. I’m always on the lookout for ways to implement these principles in my projects, whether I’m working with AI models or crafting sleek React components.

As I look ahead, I'm reminded that software engineering is an ever-evolving field. Staying adaptable and open to change is crucial. Technologies may shift, but these laws will continue to guide us through the unpredictability of the software world.

So, what about you? Have you encountered any of these laws in your own coding journey? Or do you have your own principles that guide your development practices? I’d love to hear your stories—let’s keep the conversation going over coffee!


Connect with Me

If you enjoyed this article, let's connect! I'd love to hear your thoughts and continue the conversation.

Practice LeetCode with Me

I also solve daily LeetCode problems and share solutions on my GitHub repository. My repository includes solutions for:

  • Blind 75 problems
  • NeetCode 150 problems
  • Striver's 450 questions

Do you solve daily LeetCode problems? If you do, please contribute! If you're stuck on a problem, feel free to check out my solutions. Let's learn and grow together! 💪

Love Reading?

If you're a fan of reading books, I've written a fantasy fiction series that you might enjoy:

📚 The Manas Saga: Mysteries of the Ancients - An epic trilogy blending Indian mythology with modern adventure, featuring immortal warriors, ancient secrets, and a quest that spans millennia.

The series follows Manas, a young man who discovers his extraordinary destiny tied to the Mahabharata, as he embarks on a journey to restore the sacred Saraswati River and confront dark forces threatening the world.

You can find it on Amazon Kindle, and it's also available with Kindle Unlimited!


Thanks for reading! Feel free to reach out if you have any questions or want to discuss tech, books, or anything in between.

Top comments (0)