Reputation
2,740
Top tag
Next privilege 3,000 Rep.
Cast close & reopen votes
Badges
2 8 19
Newest
 Enthusiast
Impact
~83k people reached

1d
comment Is throwing new RuntimeExceptions in unreachable code a bad style?
@MatthewRead The execution of code intended to be unreachable is a severe bug, return null is quite likely to mask the bug because you can't distinguish the other cases where it returns null from this bug.
Jul
22
comment File sharing web application - folder PIN code entry best practice
Why PINs instead of some kind of ACL? Password sharing isn't exactly good practice.
Jul
21
comment Is an interface considered 'empty' if it inherits from other interfaces?
Being unable to specify several interfaces as type of a parameter/field etc. is a design flaw in C# / .NET.
Jul
18
comment What is the time complexity of the algorithm to check if a number is prime?
In practice we use probabilistic algorithms with runtime O((log n)^3) (or slightly lower if you use fancy multiplication algorithms) instead of AKS.
Jul
13
comment How to sort fractions (small numbers)
You forgot to subtract the q from the exponent.
Jul
13
comment Is there a name for this pattern?
I know that a few APIs following this pattern exist in C#, but usually foreach together with an enumerable is the cleaner choice. It's certainly rare enough to not count as a C# idiom.
Jul
13
comment Is there a name for this pattern?
I think this code is idiomatic in C, but in C# I'd rather use an enumerator instead of a function that either returns a value or a special terminator.
Jul
11
comment long (or bizarre) file paths
Mostly hits my media collections. If you include artist, album and song name you can get names that are pretty long. Add a few directories on top of that and you can easily hit 260. I don't think I've hit 512 yet.
Jul
11
comment long (or bizarre) file paths
Most windows APIs have a 260 char limit and it's annoying as hell.
Jul
5
comment What is the “default” software license?
-1 for "implicit statement that it's OpenSource". Just because people may view your code doesn't mean it's open source.
Jul
1
comment Recommended HTTP status code for “plan limit exceeded” response
RFC4331 might be relevant, it's about quota limits for WebDAV.
Jul
1
comment Recommended HTTP status code for “plan limit exceeded” response
There is HTTP 507 Insufficient Storage.
Jun
29
comment How to store passwords which need to be re-read
"and a 'random' number" what do you mean by that? Usually the salt is the random number.
Jun
29
comment How to store passwords which need to be re-read
Encrypting the password is slightly better than storing it in plain, but not much, since you still need to store the key somewhere.
Jun
29
comment If passwords are stored hashed, does that mean that theoretically there exists another password that could be used to log in?
@gnat The requirements for a collision resistant hash (e.g. SHA-2) and a password hash (e.g. PBKDF2, bcrypt, scrypt) are quite different. In particular the latter is slow, salted and only requires first pre-image resistance not collision resistance or second preimage resistance. So I'm not sure if it's appropriate to close a question about password hashes as a duplicate of a question about collision cryptographic/collision resistant hashes.
Jun
29
comment If passwords are stored hashed, does that mean that theoretically there exists another password that could be used to log in?
Password hashes are not necessarily collision resistant. In fact PBKDF2 and scrypt have certain trivial collisions (every password longer than one block has an equivalent, trivial to find password that has the same has.
Jun
28
comment Cleanest way to represent three states, where one can hold a Key/Value pair, and the other two are empty markers
Does the homework assignment explicitly require the deletion operation? If it does not, then I wouldn't implement it. My experience with homework assignments is that you should implement a solution that fulfills the stated requirements and nothing more.
Jun
28
comment Cleanest way to represent three states, where one can hold a Key/Value pair, and the other two are empty markers
@Carcigenicate 1) Concerning the moving you must use the proper condition to figure out how many elements to use. All elements in the same buckets and elements of subsequent buckets displaced by it. 2) I suspect your non moving approach doesn't actually work. Since if you place a new value in that slot, with the new element coming from a higher bucket, this new element would disrupt the linear scan of the lower bucket extending beyond it. So implementing move-on-delete seems to be necessary with linear scan.
Jun
28
comment Cleanest way to represent three states, where one can hold a Key/Value pair, and the other two are empty markers
Yes. AFAIK that's also the way F# implements discriminated unions, since it has to compile to the .NET type system, which is similar to java.
Jun
28
comment Cleanest way to represent three states, where one can hold a Key/Value pair, and the other two are empty markers
@Carcigenicate Only the Occupied class would contains those fields, so you can't get an invalid state. If the base class were public, somebody might be able to create a contract violating derived class, but there are workarounds for that (like internal constructors, which would prevent instantiation of other derived classes). You can make these classes immutable if you want, only accepting values via the constructor and not having setters.