Comment On Colored Logic

When developing software that requires a user interface, some of us strive for a Model-View-Controller architecture to ensure ease of change to the UI and data components. Others will couple their business and display logic a little more tightly, using variables and classes to go between the two. And then there are the few (Adam Courtney's colleague included) who use the color of a UI component to determine business logic and program flow ... [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Colored Logic

2005-08-31 13:33 • by bigr
That code looks awfully familiar...

Re: Colored Logic

2005-08-31 13:39 • by jvm
42526 in reply to 42525
neat.

Re: Colored Logic

2005-08-31 13:40 • by Mike R
42527 in reply to 42525
bigr:
That code looks awfully familiar...




Translation: I wrote this some time in the distant past and am embarassed to admit its mine.



Re: Colored Logic

2005-08-31 13:42 • by Mung Kee
What's wrong with a business logic color coding scheme?  If it's
good enough for the Dept. of Homeland Security....er....I
mean......nevermind. 

Re: Colored Logic

2005-08-31 13:42 • by Colin
I knew there had to be a better way then model classes!





I KNEW IT.  Here I was using the phases of the moon.... and the
pressure of the mouse clicks.  (Everyone knows new people click
with less pressure....)

Re: Colored Logic

2005-08-31 13:43 • by loneprogrammer
So the problem here is using magic numbers, right?

Re: Colored Logic

2005-08-31 13:46 • by dubwai

I swear some people are writing code on acid.  I'd love to be there when someone wants to change the color scheme.


[manager] We've been asked to update the color scheme to fit the corporae standard.  I've got the intern on it.


[developer] Wait, the logic depends on the RGB values of the components.


[manager] What?  Why?!


Now here's the game, kind of like madlibs:  What's the developers response?  I'd get it going but I can't even think of a reason.  I need to eat.

Re: Colored Logic

2005-08-31 13:47 • by Mike R
42532 in reply to 42528
Mung Kee:
What's wrong with a business logic color coding scheme?  If it's
good enough for the Dept. of Homeland Security....er....I
mean......nevermind. 




If Form1.Picture1.Color = RGB(255,0,0) Then

    MessageBox "Warning: Terror Alert Red!", vbIconExclamation

End If



Probably not proper VB, but good enough for TDWTF

Re: Colored Logic

2005-08-31 13:48 • by BSP
42533 in reply to 42530
This isn't a WTF: it's obvious that the programmer was working in a low memory environment so he reused the members of the UI classes as state variables rather than bloating memory with some of his own. Commendable!


Re: Colored Logic

2005-08-31 13:50 • by Mike R
42534 in reply to 42533
Anonymous:
This isn't a WTF: it's obvious that the
programmer was working in a low memory environment so he reused the
members of the UI classes as state variables rather than bloating
memory with some of his own. Commendable!





There's just one flaw with that: It's VB!!!! the only programming language I know of that requres four floppies of runtime for a simple measly "Hello World" app.

Re: Colored Logic

2005-08-31 13:51 • by John Smallberries
42535 in reply to 42534
Mike R:
Anonymous:
This isn't a WTF: it's obvious that the
programmer was working in a low memory environment so he reused the
members of the UI classes as state variables rather than bloating
memory with some of his own. Commendable!







There's just one flaw with that: It's VB!!!! the only programming language I know of that requres four floppies of runtime for a simple measly "Hello World" app.



what's a "floppy"?



Re: Colored Logic

2005-08-31 13:53 • by titltn21
42536 in reply to 42530

loneprogrammer:
So the problem here is using magic numbers, right?


The concern is that there is a set amount of magic numbers (256 * 256 * 256).  It is just a matter of time before all possibilities are used up.  The developer then will have to use window position or frame size for additional options.  Appears to have painted himself in a corner on this one.

Re: Colored Logic

2005-08-31 13:54 • by dubwai
42537 in reply to 42533

Anonymous:
This isn't a WTF: it's obvious that the programmer was working in a low memory environment so he reused the members of the UI classes as state variables rather than bloating memory with some of his own. Commendable!


Yes, this is obvious.  Obviously bullshit.

Re: Colored Logic

2005-08-31 13:56 • by Mike R
42538 in reply to 42535
John Smallberries:


what's a "floppy"?






Its like a compact flash card, but bigger, suceptible to magnetic
fields, and easily damaged. They generally hold a lot less than compact
flash cards, too. See http://www.webopedia.com/TERM/f/floppy_disk.html
for additional information, or simply refer to google.com

Re: Colored Logic

2005-08-31 13:59 • by scheky
42539 in reply to 42534

Mike R:
Anonymous:
This isn't a WTF: it's obvious that the programmer was working in a low memory environment so he reused the members of the UI classes as state variables rather than bloating memory with some of his own. Commendable!


There's just one flaw with that: It's VB!!!! the only programming language I know of that requres four floppies of runtime for a simple measly "Hello World" app.


Really?  Then you really aren't all that perceptive.  Runtime files (usually known as Dynamic Link Libraries...you know dll files?) have been around for ages.  Most OS interpretations of C++ required a few core DLLs to function.  The only reason you didn't need to distribute them is that they included them with the OS usually.  Do you think Pearl runs without a runtime?  Java?  Have you TRIED to run java without the JVM?  How about Python? 


Is there some magic I'm unaware of that I've been missing for all these years? 


Hell, the only reason that VB had P-Code to start with was because it was actually once considered ADVANTAGEOUS.  Moore's Law hadn't really taken off in the business world yet and p-code with a runtime takes less space than a compiled app on a harddrive.  Now that's a moot point, but then it was big.


Now, I'm not saying VB is a stellar language, but if you are going to make a blanket statement, please don't make one that obviously makes you look like a complete and total idiot.


Do they even teach these kids anything in school these days?  Yeesh.

Re: Colored Logic

2005-08-31 14:00 • by Adam Courtney
42540 in reply to 42534

Mike R:
Anonymous:
This isn't a WTF: it's obvious that the programmer was working in a low memory environment so he reused the members of the UI classes as state variables rather than bloating memory with some of his own. Commendable!


There's just one flaw with that: It's VB!!!! the only programming language I know of that requres four floppies of runtime for a simple measly "Hello World" app.


Actually it's Fox Pro,  and the quilty party was long gone before I got here.

Re: Colored Logic

2005-08-31 14:02 • by John Smallberries
Alex Papadimoulis:



MsgBox "There was an error creating the client. " & _
"Please ensure all required fields were entered."


Yeah, don't validate the input or anything...wait for it fail, then change the control color.


Re: Colored Logic

2005-08-31 14:05 • by El Duderino
42542 in reply to 42531
dubwai:

I swear some people are writing code on acid.  I'd love to be there when someone wants to change the color scheme.


[manager] We've been asked to update the color scheme to fit the corporae standard.  I've got the intern on it.


[developer] Wait, the logic depends on the RGB values of the components.


[manager] What?  Why?!


Now here's the game, kind of like madlibs:  What's the developers response?  I'd get it going but I can't even think of a reason.  I need to eat.



[developer]  Because that's what marketing put in the requirements!
or
[Paula]  I'm Brillant!

Re: Colored Logic

2005-08-31 14:06 • by dubwai
42543 in reply to 42540
Anonymous:


Actually it's Fox Pro,  and the quilty party was long gone before I got here.



Hmmm.  I wouldn't describe this as quilty.  More of a highly-flammable, fuzzy, poly-blend blanket.

Re: Colored Logic

2005-08-31 14:10 • by TheDauthi
I think this is my favorite WTF ever.  I think I want to use this
concept in my current code, except I program IVRs, so I'd have to use
tone of voice...

Re: Colored Logic

2005-08-31 14:14 • by ammoQ
My guess: everything was so tightly seperated that the coder found no
other way to determine whether or not the operation was successfull
without changing that other, probably not-at-all better code.

Re: Colored Logic

2005-08-31 14:17 • by Mung Kee
42547 in reply to 42541
John Smallberries:
Alex Papadimoulis:



MsgBox "There was an error creating the client. " & _
"Please ensure all required fields were entered."


Yeah, don't validate the input or anything...wait for it fail, then change the control color.





Meanwhile, the labels on the client are changing to every color in the
RGB scale so the user is wondering WTF is going on.  I hope they
have a color legend.

Re: Colored Logic

2005-08-31 14:18 • by dubwai
42548 in reply to 42533

Anonymous:
This isn't a WTF: it's obvious that the programmer was working in a low memory environment so he reused the members of the UI classes as state variables rather than bloating memory with some of his own. Commendable!


What's really sad about this is that this is exactly the kind of thinking that many developers use when trying to minimize memory footprints.  Yeah, get rid of that one byte.  That's going to really make a huge difference in a GUI application. Ignore all the real memory usage problems.  Totally commendable, for sure.

Re: Colored Logic

2005-08-31 14:19 • by aslkdfjhg
And its data storage mechanism is based on the popular MPG database framework!

Re: Colored Logic

2005-08-31 14:21 • by KEncho
I remember seeing the same, but using images instead of colours. If the
image was an "OK" icon, then it was ok. If it was a "wrong" icon, it
was not ok  lol

Re: Colored Logic

2005-08-31 14:21 • by Adam Courtney
42551 in reply to 42548
dubwai:

Anonymous:
This isn't a WTF: it's obvious that the programmer was working in a low memory environment so he reused the members of the UI classes as state variables rather than bloating memory with some of his own. Commendable!


What's really sad about this is that this is exactly the kind of thinking that many developers use when trying to minimize memory footprints.  Yeah, get rid of that one byte.  That's going to really make a huge difference in a GUI application. Ignore all the real memory usage problems.  Totally commendable, for sure.



This coder did not have any memory considerations when creating this.


 

Re: Colored Logic

2005-08-31 14:21 • by dubwai
42552 in reply to 42546

ammoQ:
My guess: everything was so tightly seperated that the coder found no other way to determine whether or not the operation was successfull without changing that other, probably not-at-all better code.


I think it's pretty obvious that this code's problem it has no model.  The internal state and the view of it are completely coupled in unholy matrimony.  I've dealt with this kind of 'design' before and it's a nightmare to maintain.  Change the text of a selection and about dozen bugs appear.

Re: Colored Logic

2005-08-31 14:23 • by dubwai
42553 in reply to 42551
Anonymous:
dubwai:

Anonymous:
This isn't a WTF: it's obvious that the programmer was working in a low memory environment so he reused the members of the UI classes as state variables rather than bloating memory with some of his own. Commendable!


What's really sad about this is that this is exactly the kind of thinking that many developers use when trying to minimize memory footprints.  Yeah, get rid of that one byte.  That's going to really make a huge difference in a GUI application. Ignore all the real memory usage problems.  Totally commendable, for sure.



This coder did not have any memory considerations when creating this.



I didn't think so. I was more directing that at the person who thought this was 'clearly' for memory savings.

Re: Colored Logic

2005-08-31 14:24 • by Cheddar
42554 in reply to 42546
"tightly seperated". I think I'll use
this in my next presentation. My app is tightly seperated  to
provide context sensetive error reporting.

Re: Colored Logic

2005-08-31 14:27 • by Mike R
42555 in reply to 42539
scheky:

Mike R:
Anonymous:
This isn't a WTF: it's obvious that the programmer was
working in a low memory environment so he reused the members of the UI
classes as state variables rather than bloating memory with some of his
own. Commendable!


There's just one flaw with that: It's VB!!!! the only programming language I know of that requres four floppies of runtime for a simple measly "Hello World" app.


Really?  Then you really aren't all that perceptive. 
Runtime files (usually known as Dynamic Link Libraries...you know dll
files?) have been around for ages.  Most OS interpretations of C++
required a few core DLLs to function.  The only reason you didn't
need to distribute them is that they included them with the OS
usually.  Do you think Pearl runs without a runtime? 
Java?  Have you TRIED to run java without the JVM?  How about
Python? 





Of course, I'd say Java was piggish, as well. And Yes, I realise a
windows app won't run without windows. But when a windows app won't run
without the 4-5MB of extra garbage tacked along with it, there's
something wrong. Anyway, its been established that its FoxPro, so this
argument is moot.




Is there some magic I'm unaware of that I've been missing for all these years?




I could go into how DOS COM files fit into 64k, needed next to
nothing and could be written to not only not rely on the OS, but also
no rely on the system or video ROMs. But, that would be pointless.





Hell, the only reason that VB had P-Code to start with was because
it was actually once considered ADVANTAGEOUS.  Moore's Law hadn't
really taken off in the business world yet and p-code with a runtime
takes less space than a compiled app on a harddrive.  Now that's a
moot point, but then it was big.




Can you please tell me the advantage to this? There is only ONE
advantage I can think of and it surely wasn't about to pan out in VB,
and that would be one of portability.






Now, I'm not saying VB is a stellar language, but if you are going
to make a blanket statement, please don't make one that obviously makes
you look like a complete and total idiot.


I'm not the only one to do that, believe me.




Do they even teach these kids anything in school these days?  Yeesh.




You're likely younger than I am. So, do they?




Re: Colored Logic

2005-08-31 14:32 • by Daniel T
I get it - the WTF is that the colors don't match.  And that
everything is primary colors, which would make your eyes hurt after a
while...



--Daniel T

Re: Colored Logic

2005-08-31 14:34 • by Richard Nixon
42557 in reply to 42555
Mike R:
scheky:

Mike R:
Anonymous:
This isn't a WTF: it's obvious that the programmer was
working in a low memory environment so he reused the members of the UI
classes as state variables rather than bloating memory with some of his
own. Commendable!


There's just one flaw with that: It's VB!!!! the only programming language I know of that requres four floppies of runtime for a simple measly "Hello World" app.


Really?  Then you really aren't all that perceptive. 
Runtime files (usually known as Dynamic Link Libraries...you know dll
files?) have been around for ages.  Most OS interpretations of C++
required a few core DLLs to function.  The only reason you didn't
need to distribute them is that they included them with the OS
usually.  Do you think Pearl runs without a runtime? 
Java?  Have you TRIED to run java without the JVM?  How about
Python? 





Of course, I'd say Java was piggish, as well. And Yes, I realise a
windows app won't run without windows. But when a windows app won't run
without the 4-5MB of extra garbage tacked along with it, there's
something wrong. Anyway, its been established that its FoxPro, so this
argument is moot.




Is there some magic I'm unaware of that I've been missing for all these years?




I could go into how DOS COM files fit into 64k, needed next to
nothing and could be written to not only not rely on the OS, but also
no rely on the system or video ROMs. But, that would be pointless.





Hell, the only reason that VB had P-Code to start with was because
it was actually once considered ADVANTAGEOUS.  Moore's Law hadn't
really taken off in the business world yet and p-code with a runtime
takes less space than a compiled app on a harddrive.  Now that's a
moot point, but then it was big.




Can you please tell me the advantage to this? There is only ONE
advantage I can think of and it surely wasn't about to pan out in VB,
and that would be one of portability.






Now, I'm not saying VB is a stellar language, but if you are going
to make a blanket statement, please don't make one that obviously makes
you look like a complete and total idiot.


I'm not the only one to do that, believe me.




Do they even teach these kids anything in school these days?  Yeesh.




You're likely younger than I am. So, do they?







FLAME ON!



Great response - bravo, bravo.

Re: Colored Logic

2005-08-31 14:35 • by ammoQ
42558 in reply to 42552
dubwai:

ammoQ:
My guess: everything was so
tightly seperated that the coder found no other way to determine
whether or not the operation was successfull without changing that
other, probably not-at-all better code.


I think it's pretty obvious that this code's problem it has no
model.  The internal state and the view of it are completely
coupled in unholy matrimony.  I've dealt with this kind of
'design' before and it's a nightmare to maintain.  Change the text
of a selection and about dozen bugs appear.





We all know, sometimes a well-meaning SW designer hides just too much
of the (supposedly) internal state of a module, so other modules have
to rely on side effects to find out what's actually going on. Of course
the right way to solve that would be to change the model, but there may
be other constraints (like: no time left) that make it difficult to do
so; the coder of this WTF obviously thought that relying on the color
is less problematic (less likely to change) than relying on the text of
the label.

Re: Colored Logic

2005-08-31 14:37 • by DZ-Jay
42559 in reply to 42542
El Duderino:
dubwai:

I swear some people are writing code on acid.  I'd love to be there when someone wants to change the color scheme.


[manager] We've been asked to update the color scheme to fit the corporae standard.  I've got the intern on it.


[developer] Wait, the logic depends on the RGB values of the components.


[manager] What?  Why?!


Now here's the game, kind of like madlibs:  What's the
developers response?  I'd get it going but I can't even think of a
reason.  I need to eat.



[developer]  Because that's what marketing put in the requirements!
or
[Paula]  I'm Brillant!





[developer] Because I'm a genius, Seriously.



[manager] Brillant!





    dZ.

Re: Colored Logic

2005-08-31 14:43 • by David
42560 in reply to 42556

Anonymous:
I get it - the WTF is that the colors don't match.  And that everything is primary colors, which would make your eyes hurt after a while...

--Daniel T


 


Indeed.  I would have preferred a nice Mauve.  Or Taupe.  Lavender would also be quite soothing. 

Re: Colored Logic

2005-08-31 14:43 • by dubwai
42561 in reply to 42558
ammoQ:
dubwai:

ammoQ:
My guess: everything was so tightly seperated that the coder found no other way to determine whether or not the operation was successfull without changing that other, probably not-at-all better code.


I think it's pretty obvious that this code's problem it has no model.  The internal state and the view of it are completely coupled in unholy matrimony.  I've dealt with this kind of 'design' before and it's a nightmare to maintain.  Change the text of a selection and about dozen bugs appear.




We all know, sometimes a well-meaning SW designer hides just too much of the (supposedly) internal state of a module, so other modules have to rely on side effects to find out what's actually going on. Of course the right way to solve that would be to change the model, but there may be other constraints (like: no time left) that make it difficult to do so; the coder of this WTF obviously thought that relying on the color is less problematic (less likely to change) than relying on the text of the label.


Generally, it's difficult for a view to render something that the model is hiding unless your model is a Holub-esque 'render yourself' model.  So I'm wagering that there is no internal model.  The business code is embedded in the controls.  There is no state other than that of the gui components.  I've seen it too many times to count.

Re: Colored Logic

2005-08-31 14:44 • by jeremydwill
I think you folks missed the boat on this one. The WTF is that it is not accessibility enabled. What if the use is color-blind? Then what is the code supposed to do? [;)]

Re: Colored Logic

2005-08-31 14:44 • by Just another WTF
42563 in reply to 42557

As pointed out previously the obvious problem is that some silly manager might want to change the color of the error dialog to better match the new clock behind his desk.  So obviously the best solution would be make all the colors involved configuration settings that way the maintainer can change the color of the dialogs and the color senstivity of these brillant programmic responses at the same time with out destroying the program logic.  Something on the lines of :


    If lblClientNum.ForeColor = wftPendingColor Then
        MsgBox "Client was created but is pending activation."
    ElseIf lblClientNum.ForeColor = wtfItWorkedColor Then
        MsgBox "Client was created and was successfully activated."
    ElseIf lblClientNum.ForeColor = wtfTotalScrewUpColor _
            And lblClientNum.Caption = "999999" Then
        MsgBox "There was an error creating the client. " & _
               "Please ensure all required fields were entered."
    End If

Re: Colored Logic

2005-08-31 14:45 • by dubwai
42564 in reply to 42560
Anonymous:

Anonymous:
I get it - the WTF is that the colors don't match.  And that everything is primary colors, which would make your eyes hurt after a while...

--Daniel T


 


Indeed.  I would have preferred a nice Mauve.  Or Taupe.  Lavender would also be quite soothing. 



That's probably how this was discovered.  The colors were deemed offensive but when changed, the code stopped working.

Re: Colored Logic

2005-08-31 14:45 • by jeremydwill
42565 in reply to 42562

Aargh! *User*, not *use*!


Stupid EBKAC.

Re: Colored Logic

2005-08-31 14:48 • by John Smallberries
42566 in reply to 42558
ammoQ:
dubwai:

ammoQ:
My guess: everything was so
tightly seperated that the coder found no other way to determine
whether or not the operation was successfull without changing that
other, probably not-at-all better code.


I think it's pretty obvious that this code's problem it has no
model.  The internal state and the view of it are completely
coupled in unholy matrimony.  I've dealt with this kind of
'design' before and it's a nightmare to maintain.  Change the text
of a selection and about dozen bugs appear.





We all know, sometimes a well-meaning SW designer hides just too much
of the (supposedly) internal state of a module, so other modules have
to rely on side effects to find out what's actually going on. Of course
the right way to solve that would be to change the model, but there may
be other constraints (like: no time left) that make it difficult to do
so; the coder of this WTF obviously thought that relying on the color
is less problematic (less likely to change) than relying on the text of
the label.


Nice try, but you just can't justify this level of WTFery.

Simply changing
Call SaveNewClientData

to
result =  SaveNewClientData()

would go a long way.

Re: Colored Logic

2005-08-31 14:53 • by Ayende Rahien
This is about as scary a code as I've seen.

I would really like to hear the justification for this one.

Re: Colored Logic

2005-08-31 14:58 • by John Smallberries
42568 in reply to 42556
Anonymous:
I get it - the WTF is that the colors don't match.  And that
everything is primary colors, which would make your eyes hurt after a
while...



--Daniel T


Green is a primary color?



(sorry, sometimes I can't help being an asshole...)

Re: Colored Logic

2005-08-31 14:58 • by Otto
42569 in reply to 42563

Anonymous:
ElseIf lblClientNum.ForeColor = wtfTotalScrewUpColor _


Finally, a sensible use for Hungarian notation. [:D]

Re: Colored Logic

2005-08-31 14:58 • by WIldpeaks
Rohhh, nice one, background color-based logic, definitly brillant [:D]

Re: Colored Logic

2005-08-31 14:59 • by Adam Courtney
42571 in reply to 42567

Ayende Rahien:
This is about as scary a code as I've seen.
I would really like to hear the justification for this one.


There is none.

Re: Colored Logic

2005-08-31 15:00 • by ammoQ
42572 in reply to 42566
John Smallberries:
ammoQ:


We all know, sometimes a well-meaning SW designer hides just too much
of the (supposedly) internal state of a module, so other modules have
to rely on side effects to find out what's actually going on. Of course
the right way to solve that would be to change the model, but there may
be other constraints (like: no time left) that make it difficult to do
so; the coder of this WTF obviously thought that relying on the color
is less problematic (less likely to change) than relying on the text of
the label.


Nice try, but you just can't justify this level of WTFery.

Simply changing
Call SaveNewClientData

to
result =  SaveNewClientData()

would go a long way





But this requires access to the source of the SaveNewClientData procedure, which may not be the case in this project.



dubwai:

Generally, it's difficult for a view to render something that the
model is hiding unless your model is a Holub-esque 'render yourself'
model.  So I'm wagering that there is no internal model.  The business
code is embedded in the controls.  There is no state other than that of
the gui components.  I've seen it too many times to count.






I aggree that this software definitely does not follow the MVC
paradigm. Anyway, there could be some part of the program which could
generously be considered "internal model" although it somehow has
access to the controls, so it sets text and color of a label according
to the result of the operation.

Re: Colored Logic

2005-08-31 15:03 • by ammoQ
42573 in reply to 42567
Ayende Rahien:
This is about as scary a code as I've seen.

I would really like to hear the justification for this one.


Let's assume the programer decided to take the label as an indicator of
the success of the operation because he has no easy way to directly
find out.

Relying on the color might be safer than relying on the text of the
label, since the label text could be translated, corrected, contain
variable parts etc. while the color is always the same for a result.

Re: Colored Logic

2005-08-31 15:09 • by Bustaz Kool
42574 in reply to 42531
dubwai:

I swear some people are writing code on acid.  I'd love to be there when someone wants to change the color scheme.


[manager] We've been asked to update the color scheme to fit the corporae standard.  I've got the intern on it.


[developer] Wait, the logic depends on the RGB values of the components.


[manager] What?  Why?!


Now here's the game, kind of like madlibs:  What's the developers response?  I'd get it going but I can't even think of a reason.  I need to eat.



Ita erat quando hic adveni    (It was that way when I got here...)


 

Re: Colored Logic

2005-08-31 15:16 • by ReligousFlameWarrior
AmmoQ - with all of the defense of these WTFs the past couple of days, I beginning to think you authored quite a few yourself.



No really, why are defending such code.  If what you speculate is
true, then this code, and code like it, should never see the light of
day.

« PrevPage 1 | Page 2 | Page 3Next »

Add Comment