In SX Microcontrollers, SX/B Compiler and SX-Key Tool, PJMonty wrote: John, As a general rule of thumb, "elegant" to me is code that I can easily read and understand years after I have written it without working hard. Programmers often try to squeeze code into tiny spaces (or make it super fast) without needing to. While your question sounds like a simple hypothetical exercise, I would like to suggest that unless code [b]needs[/b] space or speed optimization, then don't bother. If the code works and is easy to read, then you have written excellent code. BTW, Bean's suggestion is a [b]perfect[/b] example of a coding style that makes the code [i]easier[/i] to comprehend. His use of the defined constant "CLOSED" means that the code reads even more like English. Remember, when reading source code, [b]you[/b] become the CPU, since you have to parse the code and "run it in you head" to understand it. Bean's example is something you could read a hundred years from now and understand easily. It doesn't get much easier than "IF Switch1 = CLOSED THEN..." for human comprehension. [list]Thanks, PeterM[/list] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=157351#m157416 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)