Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
CPColin
Sep 9, 2003

Big ol' smile.
Except you're always trying at least once, but the saying says to try only if you don't succeed first.

Adbot
ADBOT LOVES YOU

CPColin
Sep 9, 2003

Big ol' smile.
code:
if (!succeed())
{
   while (!try());
}

CPColin
Sep 9, 2003

Big ol' smile.
Are you familiar with the meaning of the phrase "if at first"?

CPColin
Sep 9, 2003

Big ol' smile.
I was reading a job posting and got to the part that said, "Our code is highly structured PHP." and closed it.

CPColin
Sep 9, 2003

Big ol' smile.
Because succeed() and try() are two different functions, obviously!

CPColin
Sep 9, 2003

Big ol' smile.
code:
//added this
Thanks. Great comment.

CPColin
Sep 9, 2003

Big ol' smile.
My favorite was when my bank or T-Mobile or something started rejecting my password because it didn't support the special characters I was using. It rejected them as I was logging in with the password I already had.

I still don't get that. If I want wacky Unicode in my passwords, I should be allowed to!

CPColin
Sep 9, 2003

Big ol' smile.
"Please paste your security image in the box below."

CPColin
Sep 9, 2003

Big ol' smile.

Suspicious Dish posted:

half rant / half question: does anybody hate the "programmers are introverted, we must be alone, in our own offices, to prevent ~*~ breaking the flow ~*~" meme thing

I'm not a big fan of pair programming, because I don't like the time it takes to watch the other person type, but part of the reason I turned down a job offer a year ago was because it would have put me alone in an office. I felt like one of my strengths was the ability to turn around in my chair and help the people who sit next to and behind me. I also knew that, if I were cooped up in an office all day, I would quickly start to fit the stereotype and it took me a while to break out of that stereotype when I started my current job.

CPColin
Sep 9, 2003

Big ol' smile.
I discovered today that Java allows ဪ in identifier names, but not 💩. I guess the first one counts as a letter, but the pile of poo is just a pile of poo.

CPColin
Sep 9, 2003

Big ol' smile.

canis minor posted:

Are there any resources on this I can read explaining "why"? I'd have thought that even if a character set had Ⅻ as one singular character, translating it to Unicode should have become XII. If translating XII from Unicode to that character set, it would go back to Ⅻ, but I guess it's naive of me to think so (or I guess there's a roman sentence where IV should stay IV instead of Ⅳ)

I wouldn't want character conversions to be responsible for my friend 6 having to go to the hospital to get an 4 drip.

CPColin
Sep 9, 2003

Big ol' smile.
That was one of Andy's better stories on The Office. He was originally named Walter, Jr., until his little brother came along and his parents liked him better.

CPColin
Sep 9, 2003

Big ol' smile.
On top of that, Eclipse can generate "bridge" code that make it so stuff outside of nested classes can use private members inside them. It usually doesn't affect anything, though, so you can tell Eclipse to shut up about it.

CPColin
Sep 9, 2003

Big ol' smile.
I like the slide with the gears that can't possibly turn:

http://tpm2016.zoffix.com/#/43

CPColin
Sep 9, 2003

Big ol' smile.
Probably in a way the original developer didn't expect!

CPColin
Sep 9, 2003

Big ol' smile.
I'm trying to picture what that maybe used to do and I'm drawing a blank.

CPColin
Sep 9, 2003

Big ol' smile.
I wonder if that person had any idea why that was suddenly necessary.

CPColin
Sep 9, 2003

Big ol' smile.
Me today: "Hmm. What's this unit test here that doesn't seem to run ever? Oh, it fails! Whew, fixing it was a simple change. Now what other code was calling what this test was testing? Oh, nothing. This test tests code that only the test itself calls. Great." :suicide:

CPColin
Sep 9, 2003

Big ol' smile.

Thermopyle posted:

When I use else after return it's because it seems to communicate intent better.

When I don't use it its because the if clause handles exceptional situations and the code below is used the majority of the time.

Of course, I also have to balance that against the indentation level.

Maybe this is bad, I dunno, but it always helps me figure out what's going on when I go back and work on it later.

It's good to be pragmatic about stuff like this. (But not all the time! Get it?)

CPColin
Sep 9, 2003

Big ol' smile.

rjmccall posted:

I personally would not consider any of those to be "magic numbers"; a comment on the line above like "Interpret the first four bytes as a big-endian int."

Yeah, I agree with that. For a computation where none of the pieces really has any meaning on its own, I think it's fine to skip defining constants, as long as some documentation says where the values come from.

We have code all over the place at work that looks like this:

Java code:
private static final String DESCRIPTION = "blah blah blah";

public String getDescription()
{
   return DESCRIPTION;
}
and it always makes me want to refactor it.

CPColin
Sep 9, 2003

Big ol' smile.
That's not the "horror" part.

CPColin
Sep 9, 2003

Big ol' smile.

MALE SHOEGAZE posted:

It's got to be one of those intentional 'simplicity' designs because I cannot imagine designing a language with multiple return values and not go hog wild with destructuring syntax.

Case in point: Ceylon.

CPColin
Sep 9, 2003

Big ol' smile.
Java's class and instance initialization logic only extremely rarely affect anything, but, boy, when they do, it's amazing. :allears:

(In this case, I bet the old compilers were figuring the values had already been initialized because some implicit constructor had already run or something.)

CPColin
Sep 9, 2003

Big ol' smile.

No.

CPColin
Sep 9, 2003

Big ol' smile.
fa+rt

CPColin
Sep 9, 2003

Big ol' smile.
I saw, during a code review, a bit of code that relied on another bit of code outputting an exact sequence of characters. I asked my coworker to write a unit test that verified the functionality, in case we ever rewrite the code to output a slightly different sequence of characters. What I really wanted to ask was, "How come you didn't write that unit test already?"

Then the coworker asked where to put it, how to run unit tests, etc.

CPColin
Sep 9, 2003

Big ol' smile.

taqueso posted:

Really, that's awesome and you should be happy to help someone learn. It was well after I was out of college when I had finally been burned enough by not having testing that I 'got' unit tests and why it was worth spending the energy. I wish I someone had mentored me on it earlier.

The question is, though, did it stick?

It clearly didn't stick the last handful of times I recommended during team meetings that we should all be writing more unit tests (and said coworker was nodding along).

CPColin
Sep 9, 2003

Big ol' smile.

xtal posted:

Can anyone come up with a Java reflection joke?

More like a C# reflection joke. :smug:

CPColin
Sep 9, 2003

Big ol' smile.

Volte posted:

By making Go code ugly by nature and mandating an arbitrary style, it lets you turn off that part of your brain that gives a poo poo about that, and you end up writing code twice as fast.

Bognar posted:

Go is great as a honeypot for bad opinions.

Hmm. Yes, I see.

CPColin
Sep 9, 2003

Big ol' smile.
Testicle-Driven Douchebaggery

At my old job, we had a pile of API documentation that was out-of-date because it was separate from the code and in an annoying-to-update Google doc. When I added some functionality to the API, I covered the new stuff with some unit tests and said, "If anybody needs API documentation, send them the unit test." I don't think the sole consumer of the API ever even asked for documentation, so whatever.

CPColin
Sep 9, 2003

Big ol' smile.
At my last job, we had something like fifty unit tests for years and years because nobody was being directed to write them and it was impossible to test a huge chunk of the code because it assumed there was an active HTTP request going on. I finally got sick of simple stuff failing immediately after we pushed it and, being on the Infrastructure team, decided that it was up to us to add unit testing to the list of what every developer is expected to know about. A week later, we had sixty unit tests, including a few rear end in a top hat tests I wrote that were designed to fail when developers added new values to a certain enum and didn't add tests for them. Couple months later, we had two hundred unit tests, mostly written by me.

Now I'm unemployed because management didn't see the value of our team. v:shobon:v I bet I could ask my old coworkers in a year how many unit tests they have and it'll still be two hundred.

CPColin
Sep 9, 2003

Big ol' smile.
Ha, maybe that's what management was worried about; I was about to start updating the coding standards to include starting to expect more and more unit tests to be written. This, of course, would have inflated point estimates and slowed down development. And for what? Peace of mind? Bah!

CPColin
Sep 9, 2003

Big ol' smile.
lol if you don't have a keyboard shortcut for typing ☭.

(Or Ctrl-Space, Ctrl-C, and Ctrl-V.)

I think I used theta once, in some geometric calculation.

CPColin
Sep 9, 2003

Big ol' smile.

NihilCredo posted:

The most grokkable explanation seems to be that it mimics the behaviour of calling "cd" on each argument in sequence.

Yeah, it's not "path1 + path2," it's more like "path1 and-then path2," looks like. I can see how one could assume normal concatenation logic would apply, though.

CPColin
Sep 9, 2003

Big ol' smile.

ExcessBLarg! posted:

the double-checked locking anti-pattern.

It's been a normal pattern since like Java 6, as long as you use volatile. An unfortunate consequence of the "write once, show up in Google forever" nature of blog posts.

CPColin
Sep 9, 2003

Big ol' smile.
And the classic "set a variable to a value and then immediately set it to something else" move. I'm surprised he doesn't set it back to null in the finally block with a "// GC" comment.

CPColin
Sep 9, 2003

Big ol' smile.
Ha, the missing null check made me think the assignment was unnecessary!

CPColin
Sep 9, 2003

Big ol' smile.
When I started at Experts Exchange in 2007, they were moving pretty rapidly with a site-wide redesign and somebody found it useful to be able to edit the email templates via an employee-only page on the Production website. Every now and then, we would have to instruct new employees that they needed to copy changes to the other environments, lest they be wiped out.

Once, I replaced the $username variable in a heavily used template with "CPColin". Another time, somebody in Customer Service accidentally blanked one of the more important templates. Took way too long before somebody deleted that page.

The "execute arbitrary SELECT queries on the Production database" page stayed up for a while longer, though.

CPColin
Sep 9, 2003

Big ol' smile.
I can't believe you're saying code review is bad.

Adbot
ADBOT LOVES YOU

CPColin
Sep 9, 2003

Big ol' smile.

boo_radley posted:

Quick, what's the emoji for legacy code?



Or "NO-BREAK SPACE"

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply