25
Lensflare
15d

Today I have encountered some interesting piece of code:
In order to make a button disabled, the text of that button is assigned a grey color.
And in the click handler, there is a check if the color of the text of that button is grey, then return from it and do nothing.

That might be the ugliest hack that I had ever encountered πŸ˜†

Comments
  • 16
    I'd say this code falls into a grey area...
  • 3
    If "overthinking" was a snippet of code, that'd be it
  • 4
    Whoever did this is a ducking genius in web-Frontend terms!
  • 4
    @010001111 yes. Except it wasn't web frontend but native iOS in Objective-C πŸ˜„
  • 5
    Oh webshiters. You do you, no matter what language you end up writing.
  • 4
    I am impressed, and horrified, all at the same time.

    @SortOfTested we have "standards" to up hold 🀷‍♂️
  • 10
    "Hey, the user clicked the button! What should I do?"
    "Well, it depends. Was the button...*gray* by any chance?"
  • 1
    what if you want to change the style of color used for disabled buttons?

    is this the type of situation that separation of concerns comes into play for?
  • 3
    @dotnope What kind of grey are we talking about? Something like 424242 or more like d2d2d2?

    @C0D4 We need a bot to display hex colours! (XOXO)
  • 5
    @Jilano πŸ€”something like

    @hexbot #424242
  • 2
    Or @hexbot #d2d2d2
  • 1
  • 0
    @C0D4 YES! :D

    Arigato, Mister Roboto
  • 3
    I've seen some legacy code where button background color is used as a flag in code. As in if button background is green, execute x, and if yellow, execute y and so on.
Add Comment