Skip to main content

Timeline for Many if conditions

Current License: CC BY-SA 4.0

16 events
when toggle format what by license comment
Feb 18, 2023 at 7:27 review Close votes
Feb 23, 2023 at 3:06
Jan 28, 2023 at 22:40 comment added candied_orange return lineA + lineB is unreachable after the early returns above it. Move this line to the top if you ever want to give it a chance to be called.
Jan 28, 2023 at 16:19 answer added gnasher729 timeline score: 2
Jan 28, 2023 at 12:25 comment added Filip Milovanović @Codemenot - That said, one way to solve this is, you create a class of the form { condition, thingToShow }, then you create a bunch of these objects with different conditions (which are just functions that return a bool), and stick them in a list, and then you filter them so that you take only those where condition(yourInput) returns true. Then you combine the all the different thingToShow of the remaining objects, and you render that. 2/2
Jan 28, 2023 at 12:24 comment added Filip Milovanović @Codemenot , we lack context to understand everything you're talking about as we're not working on your project, so when you're being too vague, it leads to confusion. For example, until I read your most recent comment, I didn't understand that by "draw a large matrix" you meant to draw it on paper, so that you can figure out stuff - I thought were talking about rendering it, "draw" it as part of your Angular page. But sure, go ahead, try it - you don't need to ask anyone if you should investigate the problem you're facing. 1/2
Jan 28, 2023 at 1:39 comment added user949300 It also depends what language you are using.
Jan 28, 2023 at 0:12 comment added Codemenot Doc Brown before I do that is my point about the matrix table not a valid one? I think it would help if I draw one and try to include every possible combo. I may need a large whiteboard or maybe in a SVG so I can zoom and out as there will be lots conditions. So I can count how many conditions first on paper then reduce them , if I can. I think this could be issue of X's and Y's. Or no?
Jan 28, 2023 at 0:05 comment added Codemenot Good point Doc Brown! I have alienation too....as it does become too vague. Let me take that exact snippet and post on their and then add a link here incase any of you here can answer it there.
Jan 28, 2023 at 0:03 review Close votes
Feb 4, 2023 at 3:01
Jan 28, 2023 at 0:02 comment added Codemenot At user253751 I know this approach can work well but I have multiple lines sometimes for any condition too and sometimes I think we need to say only if two variables are true and explicitly say third is not to return a view. Maybe I am overthinking maybe I need to re draw to make cleaner from scratch.
Jan 28, 2023 at 0:01 comment added Doc Brown You would probably get a lot better help when you post parts of your real code at Codreview.Stackexchange. Your example above is way-too-contrived to be useful. For example, you wrote "user enters a number". Lets call that number x. So what does "If(one)" mean? Does that mean "If(x==1)"? But what the heck then is the meaning of "If(one and two)"? Obviously, it cannot mean "If(x==1 and x==2)". If you alienate your code up to the point where it makes no sense, it becomes hard to give you a sensible answer.
Jan 27, 2023 at 23:55 comment added Codemenot Thanks guys! That's a good link gnat. From the info therein I see they have similar issue and there is no one key fits all solution. I guess some stuff I can do to start making it better is add: 1. exit earlys 2. Reduce function complexity ....and I think this may start to reduce if condition, length and overall design etc.
Jan 27, 2023 at 23:44 comment added gnat Does this answer your question? Approaches for checking multiple conditions?
Jan 27, 2023 at 23:27 comment added Stack Exchange Broke The Law StringBuilder result = ""; if(one) result.append(line1); if(two) result.append(line2); if(three) result.append(line3); return result.toString();
S Jan 27, 2023 at 23:18 review First questions
Jan 30, 2023 at 11:57
S Jan 27, 2023 at 23:18 history asked Codemenot CC BY-SA 4.0