---
title: "Discussion on \"Write better code and be a better programmer by NEVER USING ELSE statements\" | Hashnode"
description: "Discussion on \"Write better code and be a better programmer by NEVER USING ELSE statements\". I've been a professional programmer for the last several years. During this time I've risen rapidly through the ranks. I started as an intern, but I'm now the Lead Engineer responsible for a suite of products that serve over 160,000 people in over 14..."
url: "https://hashnode.com/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements/5faa95edc9b29b563d0c0e3e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Write better code and be a better programmer by NEVER USING ELSE statements](https://dglsparsons.hashnode.dev/write-better-code-and-be-a-better-programmer-by-never-using-else-statements?utm_source=hashnode&utm_medium=feed)

I've been a professional programmer for the last several years. During this time I've risen rapidly through the ranks. I started as an intern, but I'm now the Lead Engineer responsible for a suite of products that serve over 160,000 people in over 14...

Nov 10, 2020 · 7 min read · dglsparsons.hashnode.dev  
Read the article

-   [#go-cjffccfnf0024tjs1mcwab09t](https://hashnode.com/tag/go-cjffccfnf0024tjs1mcwab09t)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#beginners](https://hashnode.com/tag/beginners)
-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Douglas Parsons](https://hashnode.com/@dglsparsons)

@dglsparsons · Sheffield, UK

  
[View profile](https://hashnode.com/@dglsparsons)

Full Stack Engineer @ Shamaazi | Formula1 fan | Keen skier | Cat lover

Lead Engineer @ Shamaazi • AWS • Go • React • Terraform • Blogging weekly on cool tech / helping others to code. Follow me on Twitter to keep up.

## Responses 7

Markdown supported · ⌘↵ to post

[Maxi Contieri](https://hashnode.com/@mcsee)

[Nov 16, 2020](https://hashnode.com/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements/5faa95edc9b29b563d0c0e3e/comment/5fb1c527f37527517dc91e40)

Nice article!

I agree that else statements are problematics, hard to read as you mention. But I'd go one step further and remove IFs altogether!!

Without IFs there are no elses!

[maximilianocontieri.com/how-to-get-rid-of-annoyin…](https://maximilianocontieri.com/how-to-get-rid-of-annoying-ifs-forever)

[Paweł Świątkowski](https://hashnode.com/@katafrakt)

[Nov 13, 2020](https://hashnode.com/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements/5faa95edc9b29b563d0c0e3e/comment/5fae84568f0a026553479cfb)

Things become a little trickier with languages that do not have early return, such as Elixir ;)

[Douglas Parsons](https://hashnode.com/@dglsparsons)

[Nov 13, 2020](https://hashnode.com/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements/5faa95edc9b29b563d0c0e3e/comment/5fae84568f0a026553479cfb#reply-5fae88ccfa438d6532c7f2d1)

Absolutely. I've no experience with Elixir, but I had to caveat it for Scala (which has early returns, but they are discouraged).

[Bojan Nišević](https://hashnode.com/@boyanpro)

[Nov 11, 2020](https://hashnode.com/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements/5faa95edc9b29b563d0c0e3e/comment/5fabf1ed8f0a026553477694)

This is not good approach. There is only one sufficient principle in the craft: Every tool has its purpose and do not use a tool for a wrong purpose.

Not using a tool at all protects you when you do not know its purpose and how to use it properly. Also not using a common tool just to be protected from ignorance tells about amount of ignorance.

[Douglas Parsons](https://hashnode.com/@dglsparsons)

[Nov 11, 2020](https://hashnode.com/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements/5faa95edc9b29b563d0c0e3e/comment/5fabf1ed8f0a026553477694#reply-5fac0c6efa438d6532c7cedf)

Hi Bojan. I'm sorry to hear that this didn't strike a chord with you.

It's a dangerous argument you go down. I'm not saying that they have no purpose - they clearly do. Instead, i'm trying to illustrate that there are better alternatives for where they would normally be used.

I've not come across places where my code would benefit from `else` statements.

[Bojan Nišević](https://hashnode.com/@boyanpro)

[Nov 11, 2020](https://hashnode.com/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements/5faa95edc9b29b563d0c0e3e/comment/5fabf1ed8f0a026553477694#reply-5fac18768f0a026553477afc)

[Douglas Parsons](https://hashnode.com/@dglsparsons) That's the sad part. ;)

[Jack](https://hashnode.com/@FxF)

[Nov 11, 2020](https://hashnode.com/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements/5faa95edc9b29b563d0c0e3e/comment/5fab959a621a1f57a3d07287)

Quite ironic of you to mention the _Line of Sight rule_ and then present the code examples in one line.

[Douglas Parsons](https://hashnode.com/@dglsparsons)

[Nov 11, 2020](https://hashnode.com/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements/5faa95edc9b29b563d0c0e3e/comment/5fab959a621a1f57a3d07287#reply-5fab9c09d6009557c49f64d6)

Absolutely not intentional. Not sure why but something has removed all of the code formatting.

I've fixed this now - thanks for highlighting the problem!

[Dany Tulumidis](https://hashnode.com/@DanyTulumidis)

[Nov 11, 2020](https://hashnode.com/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements/5faa95edc9b29b563d0c0e3e/comment/5fab831f621a1f57a3d070a5)

Very interesting! I also dont like it to use else statements except in ternary expressions.

[Douglas Parsons](https://hashnode.com/@dglsparsons)

[Nov 11, 2020](https://hashnode.com/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements/5faa95edc9b29b563d0c0e3e/comment/5fab831f621a1f57a3d070a5#reply-5fab8d68d6009557c49f63ca)

Hey. Thanks for taking the time to read the article. I'm glad you enjoyed it - and glad you feel the same way :)
