Are you feeling overwhelmed? Refactor your assumptions
Tags: kotlin, career, motivation, mentalhealth
Published: 2020-01-07 10:21:03

I've read a lot of what fellow developers share on this platform.
First I would say that I'm grateful. They have been super helpful.

What I have also noticed is this pattern:

> Lots of developers are exactly as insane as I often am about all the things that they supposedly need to know. And that make them sweat and feel stressed.

This insanity comes from a good place: the desire to know always more. That's the mark of a good developer.

# Permanent stress is making you sick

But it comes at a steep price: permanent stress is a poison. 

Stress was invented by Nature to help you survive to dangerous situation. Stress is helpful, indeed life-saving, to escape predators and accidents on the highway. But then it has to be released or you will be sick.

Permanent stress in the modern world is a poison that you should not manage but refactor.

So let's try to refactor our assumptions.

You may learn one thing or two about Kotlin and Refactoring while doing so.

# Internal dialog

If I had to guess what is your internal dialog when you stress like this, it would look something like this

```kotlin
fun main() {
    val developer = Developer(name = "You?")
    developer.feelsOverWhelmed()

    // Ok, but why?
    developer.hasSoMuchThingsHeHasToLearn()

    // 🤔 Are you sure?
}

fun Developer.feelsOverWhelmed() = true

fun Developer.hasSoMuchThingsHeHasToLearn() {
    val youWantToBeSuccessfull = true
    val youCanStopProcrastinating = true
    if (youWantToBeSuccessfull) {
        if (youCanStopProcrastinating) {
            println("""You should learn full stack programming, 
                    iPhone, Android, AWS, DataScience""")
        }
    }
}

data class Developer(val name: String)
```

Ok, so you think you have to learn `JavaScript, Front-End, Back-End, iPhone, Android, AWS, DataScience`. 

Wow. That's a lot. 

That's too much.

But thank you for submitting your internal dialog for me to review.
 
Here are a few things that I notice.

# It's not about you

It's not only about you, the function `feelsOverWhelmed()` is true for everybody.

JetBrains IntelliJ helpfully highlight this issue and proposes a quick fix.

<img width="466" alt="overwhelmed-1" src="https://user-images.githubusercontent.com/459464/71886110-f4e98e80-313b-11ea-8202-6ad51b9cedb7.png">


I apply the fix.

<img width="395" alt="overwhelmed-2" src="https://user-images.githubusercontent.com/459464/71886111-f5822500-313b-11ea-9408-93a46b757f23.png">

Does `feelsOverWhelmed()` function now feels meaningful to you? 🤔 

To find out, I try to apply the refactoring option: *Inline function*.

<img width="418" alt="overwhelmed-4" src="https://user-images.githubusercontent.com/459464/71886115-f5822500-313b-11ea-8097-b6c0ef05b98f.png">

Oh, did you notice what happened?

IntelliJ simply removed the part about feeling overwhelmed. 

Rightly so. That you sometimes feel often overwhelmed tells me nothing about you, apart what I already knew: 

> You are a developer.

# Everyone wants to be successful

You still have so much thing to learn, so let's move on.

<img width="724" alt="overwhelmed-5" src="https://user-images.githubusercontent.com/459464/71886116-f61abb80-313b-11ea-808b-ed924d3d2c9a.png">

Ok, you wants to be successful.

Who doesn't? 

That tells me exactly nothing about yourself.

IntelliJ highlight the issue nicely once again if you press `Alt-Enter` on your boolean expression.

<img width="720" alt="overwhelmed-6" src="https://user-images.githubusercontent.com/459464/71886117-f61abb80-313b-11ea-8003-647867a827df.png">

Ok then, I **simplify the boolean expression**. 

# Everyone procrastinates

Your code now looks like this:

<img width="727" alt="overwhelmed-7" src="https://user-images.githubusercontent.com/459464/71886119-f61abb80-313b-11ea-83da-0829a591da60.png">

I press `F2` which is the shortcut for the action `Next highlighted error`.

<img width="703" alt="overwhelmed-8" src="https://user-images.githubusercontent.com/459464/71886121-f61abb80-313b-11ea-9e09-68dfd1161069.png">

Why does IntelliJ suggest to delete the expression?

Again, that you procrastinate tells me nothing about yourself except that you are a normal human being. 

I mean some can certainly pretend they never procrastinate, which we tell us that they are not very good at self-awareness. 

But you are better than that.

So yes, I delete that expression.

<img width="404" alt="overwhelmed-9" src="https://user-images.githubusercontent.com/459464/71886123-f61abb80-313b-11ea-99e3-ba2afaa026ac.png">

# "Success is good, procrastination is bad"

Again, I press `F2` and `Alt-Enter` for the quick fix.

<img width="521" alt="overwhelmed-10" src="https://user-images.githubusercontent.com/459464/71886126-f6b35200-313b-11ea-8f9c-828bcda97031.png">

The IDE is right.

All those hot takes that "Success is good and procrastination is bad"?

They mean nothing. We can let them go. 

I remove those variables.

# Again, there is nothing wrong with you

After removing the unused variables, I am left with..

<img width="424" alt="overwhelmed-11" src="https://user-images.githubusercontent.com/459464/71886127-f6b35200-313b-11ea-946c-ae50d0f43821.png">

`F2` and `Alt-Enter`. You are becoming good at this stuff!

As you can see, there is no reason for **you** in particular to be stressed about.

<img width="442" alt="overwhelmed-12" src="https://user-images.githubusercontent.com/459464/71886128-f6b35200-313b-11ea-9752-bd3845315012.png">

I apply the fix.

<img width="422" alt="overwhelmed-13" src="https://user-images.githubusercontent.com/459464/71886130-f6b35200-313b-11ea-9d49-83594c3c6cf8.png">

Heck, why do we even need this `developer` variable and `Developer` class?

They are not sparking joy so we let them go.


# Baby steps

Ok, we are left with an empty meaningless function. 

<img width="336" alt="overwhelmed-15" src="https://user-images.githubusercontent.com/459464/71886132-f74be880-313b-11ea-8606-15e35b65e5f5.png">

We inline it as we did for `feelsOverWhelmed()`:

<img width="461" alt="overwhelmed-16" src="https://user-images.githubusercontent.com/459464/71886133-f74be880-313b-11ea-8b7e-b30ee4e9cf8e.png">

# No Stress

So that's the final state of how I think you should refactor your internal dialog that was making you sweat.

<img width="453" alt="overwhelmed-17" src="https://user-images.githubusercontent.com/459464/71886134-f74be880-313b-11ea-80e2-183d60bba673.png">
 
 
# An algorithm to start eliminating permanent stress
  
1. Become aware of your stress.
2. Pause. Breathe.
3. Realize that permanent stress is never necessary.
4. write down what is stressing you. 
5. Later you will find a solution to eliminate the stressor.
6. Hint: speaking to someone you trust usually works wonder. 

# Learning Kotlin and refactoring in IntelliJ

To practice refactoring your internal dialog in IntelliJ, start by downloading IntelliJ Community Edition here 

https://www.jetbrains.com/idea/download

If you want to learn Kotlin, have a look at my article:

{% link https://dev.to/jmfayard/best-ways-to-learn-kotlin-from-scratch-or-from-java-with-books-or-tutorials-online-or-in-the-ide-52cm %}

Yersterday, someone asked me if I have a newsletter he can subscribe to. 

Not really, but if you insist, you can enter your email here:

https://jmfayard.substack.com/p/coming-soon

Caveat: I might never use it.