Author Topic: (Just for fun) Why sleep is important when programming  (Read 4084 times)

0 Members and 1 Guest are viewing this topic.

Offline claudehuggins

(Just for fun) Why sleep is important when programming
« on: September 23, 2016, 11:27:24 AM »
I decided it would be a good idea to stay up late last night to program one of the games I've been working on. Turns out, unsurprisingly, that's not a good idea at all.
I found my code riddled with stupid mistakes. I spent all morning fixing it. I figured it might be entertaining to show off some of these mistakes as an example of just how tired I really was.
This isn't really a "guide" or "what not to do" so much as a humorous (at least to me) look into the facepalm-inducing errors that come pre-packaged with an interest in programming.

Code: [Select]
; On an unrelated note, I'm coding this at night. Who in the world codes at night? I don't even like being on the computer in the dark. My eyes hurt and I want to go to bed.

; It's morning now. I'm reading this again. I made so many mistakes it's not even funny. Ay yi yi. Don't code at night, kids. Or when you're tired at all, really.

(method (handleEvent pEvent)
(super handleEvent: pEvent)
;         * Handle the possible said phrases here *
(if (Said 'look>')
(if (Said '/sign<gold,front,desk') (Print 2 12))  ; To my embarrassment, I had forgotten the word separator on all of these. Also, for some reason, I hadn't changed "front" to count as a qualifying adjective.
(if (Said '/sign<bin') (Print 2 2))  ; I flat-out wrote and coded a response for looking at a sign that does not exist. There is no sign on the sale bin. On another note, I probably could have coded this entire sign section more gracefully if I had actually been thinking about what I was doing.
(if (Said '/sign<door') (Print 2 3))
(if (Said '/sign') (Print 2 0))
(if (Said '/door') (Print 2 4))
(if (Said '/desk') (Print 2 5))
(if (Said '/bin')
(if (& (gEgo onControl:) ctlTEAL)
(Print 2 6)

else (Print 2 13)  ; For some reason, I had referenced a text resource here that does not exist.
(if (Said '[/around]') (Print 2 9))
(if (Said 'dance[/desk]') (Print 2 11))  ; The word separator here was outside the brackets, for some reason. This meant that only "dance desk" would work, and not "dance", which was the point of the brackets in the first place.
(if (Said 'open/door')
(if (& (gEgo onControl:) ctlGREEN)
else (Print 2 14)
)  ; This close parenthesis was the bane of my existence when trying to figure out where my code went wrong this morning. It was one line too high, meaning any input from the user whatsoever triggered this print statement, unless it was the engine parsing the phrase "open door".

A while ago, at a block party I found myself socially trapped at, I thought to myself: I need a t-shirt that says, "I'd rather be programming".

Offline Cloudee1

Re: (Just for fun) Why sleep is important when programming
« Reply #1 on: September 23, 2016, 11:41:43 AM »
Also, your if statements don't seem to close before the else statement is called

Does this actually work?

*Ah wait, I see by the comments you are using sierra syntax... which I have barely looked at, so it may very well work... nevermind
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline troflip

Re: (Just for fun) Why sleep is important when programming
« Reply #2 on: September 23, 2016, 12:25:54 PM »
I generally like to use cond statements for things like your look statements. e.g:

Code: [Select]
(cond (Said 'look>')
    ((Said '/sign<gold,front,desk')
         (Print 2 12)
    ((Said '/blahblah')
         (Print 2 13)

fwiw, I code best at night
Check out my website:
Groundhog Day Competition

Offline lance.ewing

Re: (Just for fun) Why sleep is important when programming
« Reply #3 on: September 23, 2016, 03:07:05 PM »
I think I'm fine with the coding after midnight; the code itself seems to turn out fine. It's the other decisions outside of coding that don't turn out too well, such as at 2 am thinking "I'm sooooo tired... Let's just submit this thing now without testing it on anyone else's machine, or any other browser, even though I've still got 10 hours before the deadline."

Regretting it now, but at the time I really wanted to sleep.

SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.026 seconds with 23 queries.