The tag has no wiki summary.

learn more… | top users | synonyms

15
votes
10answers
11k views

Should I use switch statements or long if…else chains?

Often when I hear about the switch statement, its put off as a way to replace long if...else chains. But it seems that when I use the switch statement I'm writing more code that I would be just ...
15
votes
6answers
5k views

Refactoring Switch Statements and is there any real use for Switch Statements at all?

I was reading this article and was wondering, do we get rid of all switch statements by replacing them with a Dictionary or a Factory so that there are no switch statements at all in my projects. ...
34
votes
14answers
9k views

Why use an OO approach instead of a giant “switch” statement?

I am working in a .Net, C# shop and I have a coworker that keeps insisting that we should use giant Switch statements in our code with lots of "Cases" rather than more object oriented approaches. His ...
8
votes
5answers
1k views

If-Else V.S. Switch end of flow

I was wondering the if if-else statements, is like a switch statement that does have a break statement. if( boolean_expression_1 ) statement_1 else if( boolean_expression_2 ) statement_2 else ...
18
votes
8answers
4k views

What is the benefit of switching on Strings in Java 7?

When I was starting to programme in Java, the fact that switch statements didn't take strings frustrated me. Then on using Enums, I realised the benefits that you get with them rather than passing ...