Boolean expressions that can involve logical operators, used for branching execution paths, which increases cyclomatic complexity.

learn more… | top users | synonyms

0
votes
0answers
35 views

c++ switch statement help pizza order. [on hold]

Im having trouble with the code running. I am pretty new to this since you can tell that its a simple problem and this is for my intro class. I must use the switch statement to calculate the bill for ...
6
votes
2answers
198 views
1
vote
1answer
35 views

A shorter way for getting variables

I have the following piece of code in my project, and that a few times: ...
8
votes
3answers
276 views

“Alien” distinguisher

I am practicing some simple Java coding problems in an attempt to learn while doing them. I would like to know if my code is redundant/is there an easier way to accomplish the same thing? Question: ...
5
votes
1answer
62 views

Effective use of branch prediction in terrain generator

I am trying to learn how branch optimization works. For an experiment, I have a recursive fractal terrain generation and I have moved all if statements to binary ...
3
votes
2answers
205 views

Multiple attempts to find the best icon

I have a series if statements where I am trying to find the highest resolution file in an set of files. Is there a way that I can refactor this code to be shorter and or cleaner? ...
6
votes
1answer
134 views

Cash Register Challenge

Challenge: Design a cash register program Specifications: Your register currently has the following bills/coins within it: 'PENNY': .01, 'NICKEL': .05, 'DIME': .10, 'QUARTER': .25, ...
4
votes
1answer
57 views

Executing a list of tasks from a database

I have a list of tasks I get from my database (as strings) and then execute. However I'm uncertain on how to implement this correctly. Currently I have implemented this in the following way: ...
8
votes
3answers
388 views

Writing multiple if tags that compare two variables

I am a beginner in C# coding, and I was trying to compare two int variables: ...
4
votes
4answers
236 views

Truncate String to target length using only whole words

I've got a bit of code that I'm wanting to tidy up. The aim is to take a String that consists of multiple words connected by a separator (It's produced using ...
10
votes
2answers
154 views

Refilling a Bejeweled Board

When you start thinking about designing a Match 3 type game, you realize that there are a great many ways to structure the rules. In this particular variant, the direction that the player swipes the ...
2
votes
1answer
47 views

Condensing multiple conditionals into function

I feel like I'm repeating a ton of code here and there's got to be a better way to do this but am just completely spacing right now. I basically have an else if ...
4
votes
2answers
89 views

Concisely adding values in a loop to a column

In my data frame I assign values to the column Register by checking another column (Source) for specific values. Based on those values, the output in Register changes. I am relatively new to R, but I ...
12
votes
1answer
63 views

Board Evaluator for Bejeweled Clone

I've been prototyping a Match 3 game (Bejeweled clone) because I have an interesting concept for one, and because it is good practice. One key aspect of my version is that the matches must contain ...
3
votes
2answers
44 views
5
votes
5answers
338 views

Extracting the location for a page with fewer conditionals

I've been given the job of trying to reduce the line count for a file that helps generate a PDF for a web app. The class itself is pdfHelper, and contains a number ...
3
votes
3answers
182 views

Parsing argument list specifying a player to be added

I want to start off by saying sorry, I wasn't able to search for this problem as I couldn't exactly describe it myself. I have a series of if-statements to account for each scenario. As you can see ...
3
votes
2answers
120 views

Hide / Show panels depending of value of a dropdown

According to the value of a dropdown menu I have to show/hide two panels. For option 'derive' and 'reject' I should show the comment panel, and just for the 'derive' panel I should also show a ...
5
votes
2answers
70 views

Finding the Greatest Integer and Ties

I'm trying to find the greatest integer of four integers and its ties. I used the following code. Is there anyway to simplify this more effectively? ...
6
votes
2answers
521 views

Javascript condition optimization

Can the following condition be optimized/simplified ? ...
7
votes
1answer
108 views

Multiplayer bowling in Ruby (follow-up: injection, single responsibility)

This is a multiplayer bowling simulator in Ruby. It allows for variable skill levels, and produces weighted random results for each player's rolls based on those skill settings. This is a complete ...
12
votes
1answer
129 views

Multiplayer bowling in Ruby, with variable skill

This is a multiplayer bowling simulator in Ruby. It allows for variable skill levels, and produces weighted random results for each roll based on those skill settings. The methods are grouped in four ...
2
votes
1answer
52 views

Conditional statements with doctor and patient information

I'm focusing on trying to write clean, modular Python 2.7.5 code. ...
18
votes
3answers
2k views

Beastly if statement, adding a course to one of 8 periods

I have this rather ghastly if statement and I'm sure there is a way to condense it, but I don't really know how. I was told a ...
1
vote
1answer
72 views

How do I bind a symbol in a conditional in Clojure? [closed]

In Ruby (on Rails) I would do this in a controller action to provide authentication: ...
11
votes
4answers
854 views

Writing null-safe code to set form values

I will ask my question using the following example: HTML ...
1
vote
1answer
70 views

Conditional AND statement- which is more readable?

Does this function automationStatusIsSuccessful = (data) -> data.Automation.Status isnt "FAILED" and data.Automation.Status isnt "COMPLETEDWITHERROR"` ...
3
votes
1answer
57 views

Complex Conditionals in a Strategy Game

I have been looking at this method for a long time and I have finally refactored it into something that I believe is much more readable. I am not totally happy with it though so I would like to get ...
2
votes
5answers
248 views

Avoiding multiple if conditions in a Car class

In this dummy structure, we have a race car manager class. this class contains a method named execute(). There is a List which contains all participating racing ...
10
votes
7answers
2k views

How to simplify this if else statement?

How would you simplify/improve the readability of this code? Because even after my attempt to improve the readability I think it still looks messy. ...
15
votes
2answers
903 views

Using large amounts of if-else statements for playing card numbers

I have a method that uses a bunch of if-else statements, and I am thinking how I could simplify it. ...
4
votes
2answers
167 views

Writing a set of JavaScript conditionals more efficiently

There must be a better way to write this, maybe with a switch statement (which for some reason I can't get to work). Basically, if one of the conditionals is true then the class in the statement is ...
4
votes
4answers
88 views

Refactoring huge if..elif in __init__ how?

I have this huge __init__ method, which is readable I think, but still doesn't feel right after watching Clean Coders videos (content of Clean Code book by Robert ...
6
votes
3answers
763 views

Simplifying a series of type checks and casts in a generic method

The if/else statements below are not good. How can I improve this method? ...
8
votes
6answers
877 views

Is it possible to optimize the following boolean checks?

The following code works and it prints out only True as it is supposed to, for all the different cases: ...
0
votes
1answer
37 views

Checking for variable being passed in Python [closed]

I have a Python script which is littered with if statements which checks for whether a variable was passed. An example is some function like this: ...
10
votes
6answers
1k views

Reducing conditional statements to avoid cyclomatic complexity

Is there a better way to write the following code fragment? I can't have more than 10 conditional statement in my method as it gives cyclomatic complexity. ...
20
votes
7answers
4k views

Find min of 3 numbers hardcoded

...
5
votes
4answers
176 views

Add-to-cart method has too many conditions

I have a method that seems to be too much for one method. I might be validating programming methodology. I just don't know what to do with it. Would a switch statement be better? Should I break it up ...
2
votes
2answers
71 views

Multiple isset block going from more specific to more generic

I have a data structure that allows for inheritance of properties, in such a way that if a property is not defined within a context, the second most specific context is checked until said property is ...
7
votes
3answers
211 views

Refactor a selection validator

I have a data table and have to validate every field in it. I have refactor this code to this below, but the complexity is 15(!!) Should I make something like dictionary with ...
8
votes
1answer
281 views

Changing button colors based on user input

I am using C# to get the user's input of how many buttons to change the color of. The buttons are in rows that have 1-10 button in each. If the user enters 11, then the entire first row will be ...
5
votes
3answers
130 views

Simplifying logic of overlapping predicates

I have 3 simple predicates and 3 simple actions to be taken based on those predicates. In my actual application they are not based on integer arithmetic, and in fact are rather expensive to compute ...
3
votes
2answers
108 views

Formatting options for a long IF statement?

I have a somewhat unwieldy IF statement and am wondering if anyone has any suggestions on how to make it more readable. One one line it was all but impossible to understand, so I broke it up into ...
6
votes
2answers
281 views

Displaying content based on the current time

I'm new to PHP and just wrote a bunch of if statements to display content based on the current time. Is there a better way of writing the following block of code ...
4
votes
2answers
72 views

Conditional Branching Using Filter

I'm using multiple jQuery filter functions to affect the background color of select objects based on the selected option and it works, but it seems bulky/redundant. Does anyone know how these filter ...
2
votes
0answers
34 views

Avoiding boundaries if-cases when filtering image matrix

I have the following MATLAB Code which I want to optimize. It's related to an image matrix (2D) which I want to filter. Though it is MATLAB code, the same problem would arise in C code. The problem ...
7
votes
3answers
396 views

Refactoring decision tree

Currently I have ...
3
votes
1answer
78 views

Breaking after one of several string replaces occur

I have a script that matches a string against ~20 different regexs for the purpose of changing it. They are ordered and formed that the string will only ever match against one. How can I avoid ...
3
votes
2answers
91 views

Simplify an if else construct with assignment before if and else

I want to simplify an if: .. else: .. construct: ...