Reputation
3,274
Top tag
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
2 9 23
Newest
 Nice Answer
Impact
~99k people reached

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
6
reviewed Approve Is overriding Object.finalize() really bad?
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
answered Recommended HTTP status code for “plan limit exceeded” response
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
reviewed Approve Do my “dal” and “fileHandler” interfaces overlap?
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
revised Cleanest way to represent three states, where one can hold a Key/Value pair, and the other two are empty markers
added 272 characters in body
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.
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 This optimization can be used even with linear scanning. It corresponds to your second approach, but uses the same field to represent special values and something that's useful (the cached hash) if the slot contains an element. It's not a bad idea, but IMO an unnecessary complication for a homework problem.