Linked Questions

56 votes
11 answers
155k views

I was cruising around the programming blogosphere when I happened upon this post about GOTO's: http://giuliozambon.blogspot.com/2010/12/programmers-tabu.html Here the writer talks about how "one ...
saunderl's user avatar
  • 665
31 votes
4 answers
10k views

I find myself writing a lot of code like this: int myFunction(Person* person) { int personIsValid = !(person==NULL); if (personIsValid) { // do some stuff; might be lengthy int myresult ...
William Jockusch's user avatar
31 votes
3 answers
62k views

What is the best practice for checking multiple conditions, in no particular order? The example in question needs to check four distinct conditions, in any order, and fail showing the correct error ...
Redandwhite's user avatar
0 votes
3 answers
1k views

Let's say we have two ifs that depend on each other: if var exists { if var is array { //Do stuff with var } else { //Resolve the problem } } else { //Resolve the ...
Mikayla Maki's user avatar
-2 votes
1 answer
2k views

Often I came across situations like this, how to write this code in a neat and clean way. One more issue I find here is performance as I am iteration a list and then it's properties. Edit : - while ...
ifelse.codes's user avatar
2 votes
1 answer
960 views

I took over a large legacy code base. It has a code like this: if ($route == 'login' || $route == 'logout' || $route == 'forgot-password') { return; } if ($loggedInUser == false && $...
Cnkt's user avatar
  • 133
-1 votes
5 answers
357 views

In my current case, I've got two variables. Let's call them action and status for ease of use. They can have any value between 1 and 9. Depending on business logic, I've to either call subActionA() or ...
Yash Capoor's user avatar
-1 votes
1 answer
877 views

I'm working a project where I found another developer wrote a method as you see it below. How would I clean those IF statements and refactor this method. Also is it ok ti set a variable to nil ? def ...
egyamado's user avatar
  • 117
0 votes
1 answer
826 views

I've got a fairly large set of booleans I'm checking in javascript, and then using them to alter the state of a layout in my React app. The whole thing is unwieldy, difficult to read, inelegant, and ...
Kevin Whitaker's user avatar
1 vote
1 answer
198 views

Whenever I feel like choosing from a list of implementations I always prefer to fill a map first and then call whatever I need based on a parameter, instead of using switch or else if statements. ...
enon's user avatar
  • 161
2 votes
4 answers
253 views

In our project there are deep and lengthy if-else structures which can be significantly shortened by a simple rearrangement. To me the shorter version would be easier to understand also. As an ...
riskop's user avatar
  • 129
3 votes
0 answers
103 views

I have an app where every object is checked based on various types of business rules. For this, i used multiple nested if-else statement which was done in one class. I am not happy with this situation ...
Arife Kübra's user avatar
218 votes
14 answers
109k views

It's an idea I've heard repeated in a handful of places. Some more or less acknowledging that once trying to solve a problem purely in SQL exceeds a certain level of complexity you should indeed be ...
175 votes
24 answers
118k views

This is a minor niggle, but every time I have to code something like this, the repetition bothers me, but I'm not sure that any of the solutions aren't worse. if(FileExists(file)) { contents = ...
51 votes
6 answers
104k views

The experts in clean code advise not to use if/else since it's creating an unreadable code. They suggest rather using IF and not to wait till the end of a method without real need. Now, this if/else ...
deviDave's user avatar
  • 2,963

15 30 50 per page