Want to deal with a lot of conditions in If statement in an elegant manner. If you refuse to abstract or change usart_error then consider using whitespace to take mercy on my eyes.
1 2 3 4 5 6 7 8 9 10 | if ( usart_error.CRCError || usart_error.DMATransferError || usart_error.FramingError || usart_error.NoiseError || usart_error.OverrunError || usart_error.ParityError ) { //... } |
If you were willing to abstract it (please do) behind a good descriptive name (please please do) the complexity is still likely to show up somewhere else, sticking you with nearly the same problem. In those cases I use something like this:
1 2 3 4 5 6 7 | return usart_error.CRCError || usart_error.DMATransferError || usart_error.FramingError || usart_error.NoiseError || usart_error.OverrunError || usart_error.ParityError ; |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.