Reputation
3,165
Top tag
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
1 16 31
Newest
 Yearling
Impact
~183k people reached

Sep
4
comment Best way to handle nulls in Java?
@Woot4Moo No, that's the wrong approach. You are silently correcting an NPE because you are letting the caller indistinctly use "" or null, which is almost never the right course of action. If you do this, you should also write in your javadoc "be aware the API treats "" and null indistinctly", at which point you must just as well simply write "null is an error" and throw an exception. Clients calling your code will become aware of the problem the first time they try using a null, so what's the big deal. And if they are accidentally passing null, then it's an ERROR in THEIR CODE.
Sep
4
comment Best way to handle nulls in Java?
@Woot4Moo So write your own code that throws an exception then. The important thing is to inform the caller that their passed arguments are wrong, and tell them as soon as possible. Silently correcting nulls is the worst possible option, worse than throwing an NPE.
Sep
4
comment Best way to handle nulls in Java?
In my opinion it makes more sense to place an assert and throw an exception if the argument is null, since it's clearly the caller's mistake. Don't silently "fix" caller mistakes; instead, make them aware of them.
Sep
4
comment Is it okay to return the “wrong” HTTP status code in order to show a more user-friendly error page?
@jwenting It seems to me you'd be subverting the intended meaning of HTTP codes. In an extreme case, you can always return a 200 and a text describing the error, but that would against the spirit of HTTP, wouldn't it? What kind of information would a 404 be leaking to an intruder, anyway? (I understand the case against a 403, though).
Sep
3
comment Is it okay to return the “wrong” HTTP status code in order to show a more user-friendly error page?
@jwenting Are you proposing subverting HTTP in exchange for (allegedly) increasing security? The same argument can be used like this: "don't follow any internet standards, because standards can be exploited by attackers."
Aug
26
reviewed Approve Using private vs company devices for development at work
Aug
17
awarded  Good Answer
Aug
7
comment Are data type declarators like “int” and “char” stored in RAM when a C program executes?
I think this answer isn't helpful. It complicates things way beyond the current level of understanding of the OP. It's clear the OP doesn't understand the basic execution model of a CPU + RAM, and how a compiler translates symbolic high-level source to an executable binary. Tagged memory, RTTI, Lisp, etc, is way beyond what the asker needs to know in my opinion, and will only confuse him/her more.
Aug
7
comment Are data type declarators like “int” and “char” stored in RAM when a C program executes?
@user16307 Try not to worry about C++ and C#. What these people are saying is way above your current understanding of how computers and compilers work. For the purposes of what you're trying to understand, the hardware does NOT know anything about types, char or int or whatever. When you told the compiler some variable was an int, it generated executable code to handle a memory location AS IF it were an int. The memory location itself contains no info about types; it's just that your program decided to treat it as an int. Forget everything else you heard about runtime type information.
Aug
6
comment Are data type declarators like “int” and “char” stored in RAM when a C program executes?
@vaxquis Jorg's answer is pretty good as well, and has my +1.
Aug
6
comment Are data type declarators like “int” and “char” stored in RAM when a C program executes?
@vaxquis I'd argue that the computer doesn't know. The compilers for C++, Java, etc. produce additional code to handle this information -- which again, I think it's a more advanced topic than what the OP is asking about -- but the hardware knows nothing of it. You have to keep track of this because the computer doesn't know how to do it; C++ (for example) merely generates code for this, so that you don't have to write it yourself. Compare this to writing assembly code. This is why I consider Ryan's answer the best for the kind of knowledge level I assume the OP to have.
Aug
6
comment Are data type declarators like “int” and “char” stored in RAM when a C program executes?
@vaxquis I don't think the OP is asking about the sort of things RTTI addresses. The OP is asking something way more basic: how does a computer "know" whether the contents of a register or a memory location is an int, or a char, or whatnot. And the answer is "the computer doesn't, but the compiler will generate code that treats the stored value differently according to the type at compile time."
Aug
6
comment Is type safety worth the trade-offs?
@MasonWheeler Agreed, that blog post is embarrassingly bad. The conclusions are also awful ("Java claims to be static, but it does this which isn't static, therefore static typing is no good"). Maybe there are better arguments out there, but this blog isn't one.
Aug
6
comment Is type safety worth the trade-offs?
The paper: Haskell vs ..., An Experiment in Software Prototyping Productivity - Paul Hudak and Mark P. Jones. It describes the results of an experiment ordered by ARPA and the US Navy.
Aug
6
comment Is type safety worth the trade-offs?
Your scenario of rapid prototyping is hinted to be wrong in Paul Hudak's paper about a US navy study which required to develop an AEGIS-like simulation in different languages, one of which was Haskell. It meets almost all your criteria: it was rapid prototyping, the requirements where ill-defined, and the cost of failure was near-zero (this being an extremely informal experiment). Haskell came out the winner in evey category: development time, exceeding the requirements, requiring fewer LOC, and producing the only working example among all contestants!
Aug
6
reviewed Approve How often should I/do you make commits?
Aug
6
comment Java difference between String a = null and String a = new String()
Agreed. But also, if the OP doesn't need to change s, they should initialize it once and make it final. No need to mess with null or empty Strings :)
Aug
6
comment Java difference between String a = null and String a = new String()
If at all possible, try to write something like final String x = "the string";. This way: a- x cannot be null, and b- x is guaranteed not to change its value during its scope, avoiding nasty surprises.
Aug
6
revised Is the benefit of the IO monad pattern for handling side effects purely academic?
added 154 characters in body
Aug
6
answered Is the benefit of the IO monad pattern for handling side effects purely academic?