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.
 
  • Locked thread
CPColin
Sep 9, 2003

Big ol' smile.
code:
public AssertionError(boolean detailMessage) {
   this("" +  detailMessage);
}
uuuuuuuuugh

code:
int maximumLength = Integer.parseInt(String.valueOf(MAXIMUM_LENGTH));
UUUUUUUGH

(hint: one of these is from java.lang!)

Adbot
ADBOT LOVES YOU

CPColin
Sep 9, 2003

Big ol' smile.
correct. I'm not sure which one is dumber, though

CPColin
Sep 9, 2003

Big ol' smile.

JewKiller 3000 posted:

the first is dumber because implicit conversions are bad and wrong

it's not even just a conversion. that syntactic sugar translates to this:

code:
this(new StringBuilder().append(defaultValue).toString());
all of which does a big pile of poo poo behind the scenes. compare that to something sensible like this:

code:
this(String.valueOf(defaultValue));
where String.valueOf() just returns "true" or "false" and ugh the Java class library designers are the worst

CPColin
Sep 9, 2003

Big ol' smile.
code:
for (K key : map.keySet())
{
   V value = map.get(key);

   // ...
}
ugh quit it

also gently caress whoever at Sun decided that Map.get() and containsKey() should take an Object instead of a value of type K.

CPColin
Sep 9, 2003

Big ol' smile.
yes, it should use entrySet(), so you don't have to do a get() for each iteration.

CPColin
Sep 9, 2003

Big ol' smile.
yes:

code:
for (Map.Entry<K, V> entry : map.entrySet())
{
   K key = entry.getKey();
   V value = entry.getValue();

   // ...
}
this is annoying, too:

code:
int value = 0;

try
{
   value = Integer.parseInt(string);
}
catch (NumberFormatException e) {}
just put "value = 0;" in the catch block! don't initialize poo poo and then immediately overwrite it!

CPColin
Sep 9, 2003

Big ol' smile.

prefect posted:

is this just a joke, or real advice? genuinely curious, as i tend to have multiple points of return and real programmers don't seem to do that

it depends. just be consistent and don't mix styles in the same chunk of code.

CPColin
Sep 9, 2003

Big ol' smile.

hmm yes a well-reasoned point

CPColin
Sep 9, 2003

Big ol' smile.
raise your hand if you love it when Eclipse hangs for several minutes when you ask it to refactor the name of a private static field!

CPColin
Sep 9, 2003

Big ol' smile.

unsanitary posted:

terrible programmer ?: if you are a terrible programmer and are starting a new job probably w/ good programmers how do you avoid getting poo poo on while you're trying to become better at it but are still bad

Ask where to look to find the answer to something, instead of asking for the answer itself. "Where would you look first?" is probably my go-to question when interviewing potential interns who are looking for an exciting summer doing scutwork at Experts Exchange.

CPColin
Sep 9, 2003

Big ol' smile.
At work we have piles of interfaces with a single method where everybody's implementation of it calls the same static method in a utility class and oh man I can't wait for us to upgrade to Java 8 so we can fix that

and then get closures and everything else wrong for a couple years

CPColin
Sep 9, 2003

Big ol' smile.
don't ask the users of my company's website.

CPColin
Sep 9, 2003

Big ol' smile.
Found this in our SVN history recently:

code:
         Collection<String> errorsToRemove = new ArrayList<String>();
         for (String error : errors)
         {
            if (error.contains("provide") && error.contains("valid") && error.contains("email"))
               errorsToRemove.add(error);
            if (error.contains("enter") && error.contains("password"))
               errorsToRemove.add(error);
         }
         for (String error : errorsToRemove)
            errors.remove(error);
Somebody has been using enhanced for loops for too long. Among other things.

CPColin
Sep 9, 2003

Big ol' smile.

coffeetable posted:

how's that goin

beats me. Eclipse Luna just freezes every time I try to use it and Linux Mint still doesn't have an openjdk 8 package.

CPColin
Sep 9, 2003

Big ol' smile.
code:
		catch (IOException ioe) {
			throw new WrapperException(WrapperExceptionCode.MAPI_IO_EXCEPTION, "Exception: '" + ioe + "'");
		}
This is not how wrappers work, Brightcove API developers.

CPColin
Sep 9, 2003

Big ol' smile.
Make an object that stores the word, the topic, and the count, then sort them using various implementations of Comparator?

CPColin
Sep 9, 2003

Big ol' smile.

compuserved posted:

please help this idiot programmer understand: why isn't a simple ValueError raised instead? why did the module authors bother subclassing ValueError here? i understand in general why exception hierarchies exist and are useful, but in this particular case i don't understand why they didn't just make use of ValueError as-is.

That's stupid and the module authors blew it. If something already exists and does the job fine, you're supposed to use it, not make another thing that does the same thing (and then not even use it).

CPColin
Sep 9, 2003

Big ol' smile.
The Eclipse developers should probably find their way to this thread, judging by the regression bugs I've been filing against Luna.

CPColin
Sep 9, 2003

Big ol' smile.
ok: https://bugs.eclipse.org/bugs/show_bug.cgi?id=445708

Nothing like adding a unit test for a bug fix, then having the next release regress the bug because the unit test disappeared?

Edit: Oh I guess Eclipse was looking at a different version of its annotations package. Because of course it ships with multiple versions.

CPColin fucked around with this message at 22:27 on Oct 7, 2014

CPColin
Sep 9, 2003

Big ol' smile.
oh good, Tomcat also has a version of javax.annotation.Generated and it has a "comment" field instead of the "comments" field that Java's version has. great.

CPColin
Sep 9, 2003

Big ol' smile.
If I were presented with that question during an interview, I would have to write that I never learned it, but figure I could look up some pseudocode on Wikipedia, then hope that I'd get a point for honesty.

(We learned Dijkstra's algorithm in one of our intro classes, but I bet I don't remember how to do that, either.)

CPColin
Sep 9, 2003

Big ol' smile.
Today I encountered CommentUtilityModel.java in our code and giggled shamelessly as I typed "CUM" and hit Ctrl-Space over and over

CPColin
Sep 9, 2003

Big ol' smile.
I don't know if we still have it, but we at least used to have an interview question that looked like this:

code:
public boolean hasValue(Collection<?> collection, Object value)
{
   boolean hasValue = false;
   Iterator<?> iterator = collection.iterator();

   while (iterator.hasNext())
   {
      if (iterator.next().equals(value)
      {
         hasValue = true;
      }
   }
   
   return hasValue;
}
Then we'd ask how the person would improve that loop. They passed the test if they said, "Just return true when you find the value."

Some people suggested adding the values to a map or sorting them and doing a binary search.

One guy finally said, "Isn't there already a Collections.contains() method?" I liked that guy.

CPColin
Sep 9, 2003

Big ol' smile.
Might not even need to keep track of a set; just remember or look up the last value you added to the merged list.

CPColin
Sep 9, 2003

Big ol' smile.
code:
StringBuilder documentation = new StringBuilder();

documentation.append("This is the documentation for the "
   + (first ? "first" : "second")
   + " thing or whatever."
   + " This isn't a real thing; it's just an example."
   + getAdditionalDocumentation());

documentation.toString();
Uh, that's not the point of using a StringBuilder.

CPColin
Sep 9, 2003

Big ol' smile.
I just took a list in Java and called stream() on it, then filter(), map(), and collect(). Even used a few lambda expressions. In production code. Am I a terrible programmer?

CPColin
Sep 9, 2003

Big ol' smile.

uncurable mlady posted:

no, but i think you just created a monad

oh no

CPColin
Sep 9, 2003

Big ol' smile.
My manager has the pin-pen merger, so it's very confusing when he tells us to "get git." Also git.

CPColin
Sep 9, 2003

Big ol' smile.
Protip for interviewing: if you send us a 4.5-page resume, we're going to expect you to be able to look at one of the pages on our site and tell us what sort of database structures you would use to produce it.

Not not listen to us repeatedly, then complain that the interview was "unfair" after we tell you no.

CPColin
Sep 9, 2003

Big ol' smile.
One time, we were trying to figure out why our servers kept apparently crashing and it turned out an intern put a System.exit(1) call in a catch block in a JSP file.

Unfortunately, his internship had already run out by then.

CPColin
Sep 9, 2003

Big ol' smile.
In interviews I've been in on, I've always been prepared to count an answer as correct if the person says, "I don't know, but I'd look here to find out."

Nobody ever does.

CPColin
Sep 9, 2003

Big ol' smile.
I'm about to hit my eighth anniversary at my current job and I'm sub-80k. :waycool:

But we work only 40 hours per week, soooo

CPColin
Sep 9, 2003

Big ol' smile.
I had a job offer from my alma mater, for less money.

It was hard to decide. :psyduck:

CPColin
Sep 9, 2003

Big ol' smile.

Bloody posted:

do we work together?

stand up and say something unique and I'll post if I hear you

Edit: oh.

CPColin
Sep 9, 2003

Big ol' smile.
Is LOGO Turing-complete or what?

CPColin
Sep 9, 2003

Big ol' smile.
I thought of a new interview question to try on people:

"please proofread this resume and correct any mistakes you find. also, condense it down to two pages"

and then I hand the person his or her own terrible resume

CPColin
Sep 9, 2003

Big ol' smile.
I got an interview by doing a half-page cover letter and a one-page resume in LaTeX, exported to PDF.

One guy recently had a 4.5-page resume that was wall-to-wall alphabet soup. He later claimed the interview was "unfair" because he didn't know what it would be abou.

Another guy, who didn't get an interview, had a disclaimer that he'd "formatted his resume for readability" and it was a solid, rectangular block of text where the font size got smaller as it went down the page.

This latest guy says he "codded" a system and everything is paragraphs instead of bullets.

CPColin
Sep 9, 2003

Big ol' smile.
Steps to making a good resume:

  • Read the job description
  • Make your resume say how you have experience doing each task in the job description
  • Proofread

CPColin
Sep 9, 2003

Big ol' smile.

Papes posted:

what's the best resource for learning how to use laTex?

I installed some editor and found a site somewhere that had a pile of templates and went from there

Adbot
ADBOT LOVES YOU

CPColin
Sep 9, 2003

Big ol' smile.
People who are safe in this thread!

  • Locked thread