Forgot how your code works? Code drunk , debug sober


Posted on March 23, 2019 by Aisah in Coding journey,Personal Improvement

Is it normal to forget how your own code works?

Is it also possible to code drunk? Just like write drunk, edit sober?

Write drunk, edit sober.

This is a quote by Ernest Hemingway, an American writer who received the Nobel prize for Literature in 1954. The quote sounds really good and resonates because drunk people tend to tell the truth in a more relatable way. They also tend to tell stuff they would not tell if they were sober. And reading about that stuff is what i think readers crave for.  Being drunk and creativity also certainly seem like bedfellows.

As a coder on a coder journey who also likes to write, I understand from this that being drunk enhances your creativity. So , Can I code drunk and edit (debug) sober? Let’s try it as an experiment: I am going to get drunk a bit and try to fix some of the code that has been bugging me ( hahah see what I did there?).  I take my favorite drink. A bottle of Smirnoff , the lemon kind, and I drink some.

Coding drunk

I have my code editor open and I try to remember what things I have been meaning to fix on the blog. I’ve been meaning to fix the responsiveness of the thumbnails (pictures of the posts). Apparently wordpress does not make these thumbnail pictures responsive by default.   I feel the pictures have been too stretchy and it has been irritating my eye. But like how should I fix it?

I take a sip again and I taste the sourness of the lemon and a few kinds of biting of the alcohol in my throat.  Zoef, an aching rush feeling thing. I am doubting. I miss my best friend. I do feel I am a social drinker.  He would say to me: Kiddo, listen to me, yes you can.

But he is not here and we haven’t talked like we used to and maybe it is my fault or maybe his. I don’t know.  Point is. He is not here and I am not there, wherever he may be. Ughl, I forgot that drinking also can make you sad. This drinking is really not helping me. I drink the rest of it. I am not sure if I am really drunk. But I do know I don’t feel smarter in any way. I thought I would feel more smart or more creative. Instead I feel somewhat sad.

Lightbulb moment.

I suddenly remember that when I made the front end template of the site, before converting it to a wordpress template, the pictures were responsive. I was using bootstrap, the card thingies, card-img-top, and I tested it so it was responsive. This means that. Somewhere in the conversion steps to wordpress the in-responsiveness (is that a word?) was introduced. I look at the code and see that wordpress uses featured images for the pictures and in the code, this is a function that does not use the img tag from the original template and thus not the same css class which is supposed to make the image responsive.

OH MY GOD. I am coding! I now just need to find where in the database the paths to the pictures are stored and figure out how to use php to echo this in the img tag. OMG I can do this. I can fix this. I am fixing this. Hopefully I can remember this later. I think I will use post its to write the stuff down. They seem like a good idea.

I really hope I will not forget how I figured this together and where in the code I am changing this. à I’ve been scrolling around on Stackoverflow and some other forums on information on the database. And I find a post on forgetting your code. They say that it’s normal to forget your code. hahah take that soberness! So even if you’re sober it’s normal to forget your code.

Here are 2 examples:

Example on internet 1: Guy fixes code while drinking his bottle of white wine ( only white works according to him) , uses post-it’s  as reminder. After a few hours and a hangover he says he has a working code but doesn’t understand his post-its. Oeps  So post-its’ not a good idea.

Example on internet 2: Guy does not drink but faces a bug at work, uses stackoverflow to find code that fixes his problem. wants to upvote the answer. Receives the message “You can’t upvote your own posts” *facepalm*.

A conclusion:

it’s normal to forget code that you have written yourself. It has nothing to do with drunk. And it is possible to code drunk i think.  About the drunk thing I don’t think I am drunk right now, maybe a bit tipsy. I do know it seems easier to be distracted with alcohol and you feel emotions stronger than when you are sober.

Forgetting code that you have written seems normal to me regardless if you have been drinking or not. Because You can only focus properly on a certain amount of information at one time. What helps is writing comments in the code, not to elaborate but to help you. Be realistic. If code speaks for itself than a comment is not needed. It is important to write comments that help you remember the purpose of the code.

What do i want you to take away from this?

  • Writing drunk , editing sober as well as Coding drunk and editing sober may seem like a good idea. But in the long run you don’t want to spend your days drunk to maintain a code or writing creatively.
  • When you’ve written your code. Reread it. if you find yourself not understanding your code just by reading it. You should put a comment for future reference. Keep the comment as simple as possible. Comment. Comment. Comment. Your code
  • Also Don’t believe everything you read on the internet. Use the common sense God , The Universe or the Deity you believe in gave you. because while it may seem like something Ernest Hemingway would say, some people who have read his work have not seen this in any of his work.

It is just like this following picture:

 

 

I really hope this post was helpful to you me fellow (coding)journey traveler

Please share or send this to someone if you think they can benefit from reading this

With a twinkle and a smile,

 

Aisah

 

 

Author

Eve

A fellow-traveler of life figuring out the way. I like to share little nuggets of wisdom i found on this journey. blogger coder baker mom of 2


Comments


Write a Reply or Comment

Your email address will not be published. Required fields are marked *


*