DEV Community

Discussion on: Six Things You Thought Senior Devs Did (But We Don't)

Collapse
 
antonfrattaroli profile image
Anton Frattaroli

1: We Don't Avoid "If" Statements
No, but I avoid else statements. They add needless cyclomatic complexity.

2: We Aren't Developing Algorithms
I mean technically all the custom code you write is an algorithm. But hopefully you're never writing from scratch a well known algorithm that certainly has a battle tested package available for it.

3: We Don't Customize Our Kernels
I've used windows since switching from amiga in 1990. It gets the job done.

4: We Don't Have Regex Memorized Either
I know a lot of regex, but I'm not going to write an email regex from scratch for the same reason I'm not implementing a sorting algorithm.

5: We Don't Know All Top 10 Hottest Languages
I'd argue against using more than is necessary to keep the skillset required to run your company lean. Or else you're stuck with needing to hire a Java+Go or a C#+Rust developer.

6: We Don't Feel Like Senior Developers Either
I'm not sure how you can't. You sit through interviews, and when you're done you need to be able to say "this person is a [junior/midlevel/senior]". You can still be "on the junior side of a senior developer", I don't understand how it'd be unclear.

Collapse
 
thephydaux profile image
Chris Kent

You can't really "avoid" else statements though, if they are not explicitly there then it is still an implicit else.

Collapse
 
codemouse92 profile image
Jason C. McDonald

I think he means explicit else. I mostly agree it adds unnecessary complexity, although there are exceptions.

Collapse
 
antonfrattaroli profile image
Anton Frattaroli

However it's worded, it works. This article gives a good example: axelerant.com/resources/team-blog/...

//Cyclomatic Complexity = 3. Npath Complexity = 4.
public int function (a, b) {
  If (a>b) {
    $return_value = a;
  } else {
    $return_value =b;
  }
  return $return_value;
}

// Above code can be rewritten as below.

//Cyclomatic Complexity = 2. Npath Complexity = 2.
public in function (a,b) {
  if(a >b) {
    return a;
  }
  return b;
}
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
codemouse92 profile image
Jason C. McDonald

Precisely.

The only time you might need an explicit else in my experience is when one or more conditions do not contain logic to leave the context (e.g. a return, break, or continue), and you have a block of code which should only be executed if none of the conditions were met.