As a relatively new developer, I worry too much about everything. I want things not only to work, but to also be the correct solutions.

This might at first sound nice, but when wrongly applied, it can have negative consequences, as I am about to narrate.

A couple of weeks ago I worked on a new Story. It was about placing a message on a webpage about available puppies for adoption. When the cursor was rolled over underlined text, a pop over message would be displayed with the list of the available puppies. In the event that no puppies were available, the text on the page would simply read “there are no puppies, but other species are available” and no pop over was necessary.

Making It Work

I had planned to optimize the code and my idea was to have the condition be only over the message without having to repeat anything else.

{dog list}
{#if weHaveDogs}
we have dogs {#else} no dogs but cats {/#if}

It looks simple, but it made the Javascript behind it overly complicated.
Nevertheless, I did it this way and went on to work on pretty much everything else.

After a while, a bunch of bugs were sent my way, two of which could be resolved if instead of placing the conditions in JavaScript, I could place them directly in the template instead.


Way Too Complex

So I asked an expert whom I deeply respect, and after looking at my implementation he bluntly said, “I don’t like the way you did it.” He advised me to create my own UI component instead. He then pointed me to a huge Javascript as an example of similar work.

I shook my head and feigned understanding at the time. My plan was to look at the code and figure out what he was talking about. Unfortunately, the code was full of single-letter variables and it felt like reading an alien language. After four hours of looking over this code, it still didn’t feel right. It could not possibly be this complicated.

At this point I remembered the advice of my acting professor, “try softer.” This was his counter to the ever present “try harder” advice. In acting, you sometimes focus too hard on playing a role in a specific manner. You are thinking about so many things that the acting comes out flat, or worse, fake. However, if you relax, it all simply flows.

This, by the way, has been one of the best pieces of advice I have ever received in my life.

Try Softer

I went back to the template, and to my amazement, when I put it back together, the new version looked something like this,

{#if weHaveDogs}
we have dogs
no dogs only cats

It adds three lines of code in the template but makes the Javascript behind it a lot simpler and more elegant to boot.

I had unnecessarily complicated things due to my initial confusion and wishing to minimize one piece of code at the expense of the overall system.

And the Lesson Is …

If the advice you are given feels unnecessarily complicated, follow your gut instead and keep searching for the elegant solution. It will probably come to you after a good sleep.