Comments

This profile is from a federated server and may be incomplete. Browse more on the original instance.

magic_lobster_party, to linuxmemes in You should

It’s found at sudo snap install mustard-gas nowadays

magic_lobster_party, to asklemmy in What's the simplest thing humans are too dumb to grasp?

0.999… means infinitely repeating 9s. There’s no more 9 to add that hasn’t already been added. If you can add another 9, then it’s not infinitely repeating.

magic_lobster_party, to asklemmy in What's the simplest thing humans are too dumb to grasp?

The difference is zero, so they’re equal.

magic_lobster_party, to asklemmy in What's the simplest thing humans are too dumb to grasp?

One way to tell if two numbers are equal is to show there’s no real number between them. Try to formulate a number that’s between 0.999… and 1. You can’t do that.

magic_lobster_party, to programmer_humor in Bill is a pro grammer

My job title is actually a data scientist. I’ve seen few pieces of code that couldn’t have been made more explainable by just using a more clear and concise naming of variables and functions. Don’t try to be so overly clever with your single letter variables and Greek alphabet. Just explain what it is with a good name.

If I’m lucky I get to write a cool new algorithm once per quarter or so. Usually it’s just a standard algorithm that has an explanation in a Wikipedia page, so I just give the name of the algorithm and a link to that page.

Most of the time we’re just doing basic data processing building on the preexisting solutions. These generally don’t need comments.

The worst code is usually when someone has tried to be overly clever (including myself). Often a simple and straightforward solution had been overlooked. Simple solutions are easier to understand and maintain. Anyone can just look at the code and get a sense of what’s going on without any comments. In many cases a simple solution has also more accurate and faster to compute.

In my work, having explainable results far outweighs anything else, and you don’t get that by writing difficult to understand code.

magic_lobster_party, to programmer_humor in Bill is a pro grammer

If you’re working in embedded I guess you can probably make an inline function or a macro so it’s taken care of at compile time.

magic_lobster_party, to programmer_humor in Bill is a pro grammer

One example was when a method's documentation said that it would throw a certain exception. Turns out it was actually throwing a different exception (deep into the code), so no wonder why we never captured it in time.

magic_lobster_party, to programmer_humor in Bill is a pro grammer

It’s probably a little bit slower, but there are other things more worth to optimize than to shave off a few microseconds from a 15 minute delay.

magic_lobster_party, to programmer_humor in Bill is a pro grammer

I think most people fail to understand what code smell really is. They think code smell means bad code. A code smell is actually an indication that something else might be bad with the code. The code smell itself might not be bad.

So when a code smell appears, it means you should identify the reason it exists and potentially fix it. In this case the bad code is a buggy external library, which is difficult for you to fix. Therefore, leaving the “code smell” is the best course of action.

Your manager was in the wrong and you were right to write comments.

magic_lobster_party, to programmer_humor in 10 months later bill revisits his spaghetti code. forgets absolutely everything and refuses to elaborate. this wouldn't have happened if Bill forgot to comment on his code

Bill writes spaghetti code.

Bill is not smart.

Don’t be like Bill.

magic_lobster_party, to programmer_humor in Bill is a pro grammer

I’ve seen it. That’s why I’m opposed to comments unless they really bring value (like explaining the why instead of the what).

magic_lobster_party, to programmer_humor in Bill is a pro grammer

So you implement A* type of algorithms every day in your work?

magic_lobster_party, to programmer_humor in Bill is a pro grammer

Or just name the variable delaySeconds if you really want to store it as an int. Bonus is that every use of the variable perfectly communicates what it is.

magic_lobster_party, to programmer_humor in Bill is a pro grammer

Chances are that the comments quickly turn out of date and become incorrect. Misleading comments is worse than no comments.

magic_lobster_party, (edited ) to programmer_humor in Bill is a pro grammer

I’ve seen code that look like this:

int delay = 15 * 60; // 10 minutes

Even if the comment was on the same line someone forgot to update it. People just ignore comments.

Better solution is to write (in C#):

TimeSpan delay = TimeSpan.FromMinutes(15)

Much more obvious what the code actually means.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • localhost
  • All magazines
  • Loading…
    Loading the web debug toolbar…
    Attempt #