2,701 reputation
2819
bio website github.com/CodesInChaos
location Frankfurt, Germany
age
visits member for 4 years, 4 months
seen 16 hours ago

Jan
20
comment REST request of different length
I would avoid returning a password hash via API. Another potential issue is that your hash looks unsalted. Password hashes should be slow and salted.
Jan
20
comment Is address 0000000C a special address?
I'd rather write 64 KiB instead of 65 kB in this case, since the power-of-two size is relevant.
Jan
16
comment What is the best way to structure and name files which contain generic classes with the same name?
The compiler internally mangles the name of generic types, adding a backtick and the number of generic parameters since .NET does not allow multiple types with the same name with a differing number of generic parameters but C# does. So the file naming convention matches what the compiler does.
Jan
15
comment Why “show line numbers” doesn't' check by default in all IDE's
Since an IDE can highlight lines in which an error (compile or runtime) occurred, line numbers are less important compared to programming in a simple text editor.
Jan
15
comment Creative Commons ShareAlike
My understanding of CC is that including a CC image in a software is only a combination and not an adaption, and thus the SA clause does not apply the the software as a whole. (Usual disclaimers, IANAL etc.)
Jan
15
comment Creative Commons ShareAlike
Reading older versions of CC might help you understand their intent. With each revision CC got less clear. You should also read the FAQ
Jan
14
comment How to solve this problem of duplicate code with a design pattern
Asking which pattern to use is the wrong approach. What matters is how to solve the problem. That solution may or may not make use of some standard design pattern.
Jan
13
comment Why are return values from compare functions in many languages defined loosely?
@user949300 1) Why would you write specific comparison code for the age of humans? You write that code once, so it's correct for every integer, and then reuse it. For example for the Child type, you'd write something like return child1.Age.CompareTo(child2.Age) where int.CompareTo needs to handle every integer. 2) -int.MinValue == int.MinValue, so negating doesn't change the sign for this case.
Jan
13
comment Why are return values from compare functions in many languages defined loosely?
Which won't work in most languages due to integer overflows. Similarly negating the value to reverse the ordering doesn't work for two's complement integers.
Jan
13
revised How to prove that this while loop calculates n^2
added 8 characters in body
Jan
9
revised Does using == in JavaScript ever make sense?
added 42 characters in body
Jan
6
revised Are there real-life usage and applications for “do while” loops?
edited body
Jan
6
comment Are there real-life usage and applications for “do while” loops?
But you're not doing anything with the data you're reading. Once you add this, do...while isn't a good match anymore.
Dec
21
comment readability vs shorter code in returning from function
The nops in your assembly code are a clear indication that JIT optimizations are disabled. Using the default settings VS disables JIT optimizations if you run in the debugger.
Dec
19
comment What is the hierarchical DB schema for this xml?
The big downside of MongoDB is that it doesn't support transactions (yet).
Dec
19
comment Is using multiple static classes with maximum one public method is a good idea
Most of those disadvantages are only an issue if you have global state or don't use higher order functions where appropriate.
Dec
18
comment Algorithm to test file equivalence
I would not use multiple hashes. One collision resistant hash (e.g. SHA2) should be enough. The probability of accidental collisions is negligible with good hashes of at least 256 bits and beyond ridiculous at 512 bits (e.g. SHA-512). Against deliberate collisions using multiple hashes is only about as strong as the strongest hash, not stronger. In general it's typically better to spend the CPU budget on using a stronger hash instead of multiple weak hashes. Personally I wouldn't even bother with byte-by-byte comparison of files if the have the same SHA-2 hash.
Dec
16
comment Is it better to use strings or int to reference enums outside the java part of the system?
In the javascript API I'd certainly use strings. In the DB both have their advantages. Some databases have built in enum support.
Dec
8
comment Adding non distinct elements to a dictionary
Perhaps a HashSet<T> is a better fit than a dictionary.
Dec
8
comment Is automatic conversion to collection types from non-collection variable a good idea?
It's pretty common, taking the form of (params T[] bla).