this post was submitted on 10 Aug 2024
576 points (97.2% liked)

Programmer Humor

19149 readers
1215 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] Prunebutt@slrpnk.net 3 points 1 month ago (23 children)

Sorry, I still don't really get the hate.

Most of the good points are common sense.

I use what I learned from watching a talk by him on clean code and I had to learn some stuff. It might be "common sense" for experienced developers. But it certainly doesn't come naturally that "functions should do one thing" to first time coders. The thought processes of when the software was developed usually isn't the best way the code should be structured in the end. But that's usually how beginners code.

It’s mostly based on what he feels is good.

In most diciplines, experience in the field is what makes the knowledge of the field. You don't always have to be able to explain why good practice does what it does.

Also: I know of some examples, where he clearly explains his reasoning, e.g. why comments shouldn't explain how the code works. (Because they're not going to be updated, when the code will be)

As a programmer, I want all relevant logic of a method to be neatly collected in one place - not scattered around deeply nested method calls.

Either you misrepresent him, or you get a hard nope from me. Staying on one layer of abstraction is most likely my most important principle of writing understandable and maintainable code.

[–] JackbyDev@programming.dev 11 points 1 month ago (6 children)

Which of these do you prefer?

A?

@Test
  public void turnOnLoTempAlarmAtThreshold() throws Exception {
    wayTooCold();
    assertEquals(“HBchL”, hw.getState());
  }

Or B?

@Test
  public void turnOnLoTempAlarmAtThreashold() throws Exception {
    hw.setTemp(WAY_TOO_COLD);
    controller.tic();
    assertTrue(hw.heaterState());
    assertTrue(hw.blowerState());
    assertFalse(hw.coolerState());
    assertFalse(hw.hiTempAlarm());
    assertTrue(hw.loTempAlarm());
  }

Uncle Bob's Clean Code suggestsOption A

[–] Threeme2189@sh.itjust.works 7 points 1 month ago (2 children)

Why in the holy mother of rust is A the better option?

[–] magic_lobster_party@kbin.run 5 points 1 month ago

His idea is that it’s faster to read that short string once you learn how to read it. But then you need to learn how to read it.

In my experience, every time I thought of something clever like this, I’ll almost always regret it a month later when I revisit the code.

load more comments (1 replies)
load more comments (4 replies)
load more comments (20 replies)