Hi J.P. On Thu, Jan 8, 2009 at 1:36 PM, J.P. Delport <jpdelp...@csir.co.za> wrote: >> >> Of course, what is - IMO - the _absolutely_ most readable is to split the >> statement in two - i.e., "a = b; if ( a ) {}" >> > > Well stated, I agree with everything you've said and second the split > statement approach.
Another paying to a false god... OK, if it's such as good idea go a re-write the following using the above suggestion: bool firstMatched = false; if ((firstMatched = fr.matchSequence("DrawArrays %w %i %i %i")) || fr.matchSequence("DrawArrays %w %i %i") ) { .... if (firstMatched) ... else ... } else if ((firstMatched = fr.matchSequence("DrawArrayLengths %w %i %i %i {")) || fr.matchSequence("DrawArrayLengths %w %i %i {") ) { .... if (firstMatched) ... else ... } else if ((firstMatched = fr.matchSequence("DrawElementsUByte %w %i %i {")) || fr.matchSequence("DrawElementsUByte %w %i {")) { .... if (firstMatched) ... else ... } else if ((firstMatched = fr.matchSequence("DrawElementsUShort %w %i %i {")) || fr.matchSequence("DrawElementsUShort %w %i {")) { .... if (firstMatched) ... else ... } So... you'd need to break the else statement.... ouch... the code will have to be logically different now... it's no longer equivialant...perhaps a one would need to use a goto to get back the original behaviour... oh yeah now we are cooking on gas... readability and maintainability is going up for sure. Then you'll need break the two matchSequence on to separate statements, perhaps one as standalone statement and one in the if statement, um... yep that will really help on readability... Lets face facts, refactoring the above without the assignment is going to make the code LESS readable and MUCH less readable. The suggestion that is breaking assignment out from conditionals always makes code more readable is deluded. Sometime it might be more readable, but many many cases it is less readable. One should also write code to be readable and maintainable, to achieve this one has to use the various language features to your advantage, prohibiting certainly usage of certainly language features because in some cases they be mis-used is shoddy reasoning. Robert. Robert. _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org