Skip to main content
Removed needless bullet marks; fixed grammar.
Source Link
  • I think there should be a limit on how many branches are acceptable.

  • For example, if I have more than eight cases inside of my switch statement, then I re-evaluate my code and look for what I can re-factor. Quite often I find that certain cases can be grouped into a separate factory. Assumption here is that there is a factory that builds strategies.

  • Either way, you can't avoid this and somewhere you will have to check in what state the object is or what type of object you are working with. You will then build a strategy for that. Good old separation of concerns :)

I think there should be a limit on how many branches are acceptable.

For example, if I have more than eight cases inside of my switch statement, then I re-evaluate my code and look for what I can re-factor. Quite often I find that certain cases can be grouped into a separate factory. My assumption here is that there is a factory that builds strategies.

Either way, you can't avoid this and somewhere you will have to check the state or type of the object you are working with. You will then build a strategy for that. Good old separation of concerns.

  • I think there should be a limit on how many branches are acceptable.

  • For example, if I have more than eight cases inside of my switch statement, then I re-evaluate my code and look for what I can re-factor. Quite often I find that certain cases can be grouped into a separate factory. Assumption here is that there is a factory that builds strategies.

  • Either way, you can't avoid this and somewhere you will have to check in what state the object is or what type of object you are working with. You will then build a strategy for that. Good old separation of concerns :)

I think there should be a limit on how many branches are acceptable.

For example, if I have more than eight cases inside of my switch statement, then I re-evaluate my code and look for what I can re-factor. Quite often I find that certain cases can be grouped into a separate factory. My assumption here is that there is a factory that builds strategies.

Either way, you can't avoid this and somewhere you will have to check the state or type of the object you are working with. You will then build a strategy for that. Good old separation of concerns.

Source Link
CodeART
  • 4.1k
  • 1
  • 22
  • 23

  • I think there should be a limit on how many branches are acceptable.

  • For example, if I have more than eight cases inside of my switch statement, then I re-evaluate my code and look for what I can re-factor. Quite often I find that certain cases can be grouped into a separate factory. Assumption here is that there is a factory that builds strategies.

  • Either way, you can't avoid this and somewhere you will have to check in what state the object is or what type of object you are working with. You will then build a strategy for that. Good old separation of concerns :)