I would like the code as close to human understanding as possible. This is why the three forms of solutions (if-then-else, switch-case-default ,? :) are suitable for matching three different processes:
- ... and now there is fibromatic quibplatz in the event, we have to do ... (otherwise ... should be done) is a mapping for
if ) - ... and now, based on the value of quibplatz, we must do this ... if it is 0, ... if it is 1 (, ... if it is none of them), if the mapping is for
switch - ... we use ... or ... based on the fact if ... has or not a mapping for
?:
Therefore, use one that compares with how you think of the actual decision as a person.
Of course, it should be emphasized that the correct OO solution in many scenarios ... and we do ... what we do this way for ..., so for .. and this way for ... where it is often used switch (but it matters for some if ), is to not use these constructs and not replace them with polymophism. Manual decision-making should be performed only when there is a real solution, and not a fake (logical) polymorphism.
user1046334
source share