I found this on Twitter this morning, and thought it very, very wise:

I found this on Twitter this morning, and thought it very, very wise:

'So much complexity in software comes from trying to make one thing do two things.' -- Ryan Singer

And then, this afternoon, it totally bit me in the ass!

I'm working on my legacy app, sprucing up the UI a bit, when I notice that at runtime, this button appears out of no where and sticks itself right in the middle of some other stuff.

A little investigation reveals that someone actually had this thought process:

"I need a new button for certain circumstances.  I know, I'll take an existing button, change its caption, change its size, change its position, and attach a completely different event handler, and I"ll have exactly what I need!!"

You know, because buttons are so expensive to create.

Comments

  1. OMG brilliant!

    That being said... the world would be a better place if someone with a time machine could go back and implement layout managers in Delphi 1...

    ReplyDelete
  2. LOL Nick you could fill the Delphi category in thedailywtf.com alone :)

    ReplyDelete
  3. Heh. but one must admit that, on a modern system, if you want to have more than a couple of millions of buttons in a UI, you should definitely consider recycling them :-)

    ReplyDelete
  4. It doesn't take millions but rather ten thousands (see http://msdn.microsoft.com/en-us/library/windows/desktop/ms724291(v=vs.85).aspx). 

    Just use inappropriate GUI elements for the job (like lots of edits on panels to display a change history in a ticket system) an you soon get some out of handle error - been there seen that :)

    ReplyDelete
  5. Stefan Glienke Wow, didn't know that. Good thing you told me though, I'll reconsider my amazing new "Each pixel's a button" UI :-D

    ReplyDelete
  6. Use TSpeedButton that does not need a new handle or FireMonkey.

    ReplyDelete
  7. Panagiotis Drivilas a speed button rules out keyboard interaction which makes your application a lot harder to use for quite a few categories of users.

    ReplyDelete
  8. Jeroen Wiert Pluimers that's true but you can emulate keyboard interaction and focus for graphic controls by handling the proper messages.

    ReplyDelete
  9. Thanks for sharing, I really like that tweet!

    ReplyDelete
  10. Stefan Glienke , Nick Hodges : submitting to the Daily WTF is not a bad idea (regardless of what you think of the site these days.)  Reason being, it's read by a lot of people and seeing Delphi code there - even bad Delphi code - would raise awareness of the language being out there.

    ReplyDelete
  11. David Millington I would have done this numerous times in the past if I were allowed to ;)

    ReplyDelete
  12. Stefan Glienke Does your employer prevent you submitting content? Understandable, but a shame...

    ReplyDelete

Post a Comment