code_junkie

Large Switch statements: Bad OOP

Nov 14th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. switch (eFoo)
  2. {
  3. case Foo.This:
  4. eatThis();
  5. break;
  6. case Foo.That:
  7. eatThat();
  8. break;
  9. }
  10.  
  11. switch (eFoo)
  12. {
  13. case Foo.This:
  14. drinkThis();
  15. break;
  16. case Foo.That:
  17. drinkThat();
  18. break;
  19. }
  20.  
  21. IAbstract
  22. {
  23. void eat();
  24. void drink();
  25. }
  26.  
  27. class This : IAbstract
  28. {
  29. void eat() { ... }
  30. void drink() { ... }
  31. }
  32.  
  33. class That : IAbstract
  34. {
  35. void eat() { ... }
  36. void drink() { ... }
  37. }
Add Comment
Please, Sign In to add comment