Switch statement

  • Thread starter Thread starter Patrick De Ridder
  • Start date Start date
P

Patrick De Ridder

"You must provide a default statement for all switch statements." according
to James W. Cooper in C# Design Patterns. I don't find this to be true in
VC#. What is the validity of Cooper's statement?

Patrick.
 
He's definitely wrong about that one, it's surprising he'd make that
comment. Was he talking about C# in particular or as a programming rule
that he happens to believe in?

BTW, I was just looking at that book the other day and wanted to get it.
Other than that aforementioned problem, do you like to book/recommend it?

Thanks,

Bill
 
Patrick:

As mentioned, this is not mandatory in C#. Perhaps the author is making a
stylistic assertion? In general, it is "good practice" to provide a default
statement.

The use of the word "must" leads me to believe, however, that this is an
error in the text.

John
 
Hello,

No, it is not a "must".

But i would say that it is good programming style to do it (most of the
time).

--
Regards,
Kristofer Gafvert - IIS MVP
Reply to newsgroup only. Remove NEWS if you must reply by email, but please
do not.
www.ilopia.com - FAQ and Tutorials for Windows Server 2003
 
When I see or hear a dev say oh its not needed, more than not I can go away
and genereate a test case that will hit that code path. Ive seen ppl change
theyre tune after. So let them code laxzyness and NOT think of what if
scenarios. I just dont say anything, I go away and find a case that will
break theyre code. The only way to educate some people :D

Works everytime for me. Push me I bite back :D Usually in the most
embarassing way:D
 
Yes I recommend it.

Patrick.


William Ryan said:
He's definitely wrong about that one, it's surprising he'd make that
comment. Was he talking about C# in particular or as a programming rule
that he happens to believe in?

BTW, I was just looking at that book the other day and wanted to get it.
Other than that aforementioned problem, do you like to book/recommend it?

Thanks,

Bill
 
Back
Top