Reputation
4,218
Top tag
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
2 21 38
Impact
~225k people reached

Jun
17
comment What's the point of implementing a Stack using two queues?
The whole point of a queue is that your enqueue time should have some vague sort of inverse correspondence with your dequeue time. In other words, with any kind of queue, given no additional information, then your best guess is that those enqueued later will be dequeued later. Sure, it might not be 100% accurate, but "queue" still (statistically) describes the overall trend. But with a stack, which exactly behaves in the opposite fashion, this is strictly the worst possible guess--at that point, it bears exactly zero resemblance to a queue. (That's 0%! Not even 1%!)
Jun
17
comment What's the point of implementing a Stack using two queues?
@yoniLavi: I don't disagree that it's popular nomenclature, but that doesn't imply it makes any sense. A calling a stack a "LIFO queue" makes as much sense as calling ethernet "wired Wi-Fi".
Jun
17
comment What's the point of implementing a Stack using two queues?
"A stack is a (LIFO) queue"... uhm, a queue is a waiting line. Like the line for using a public restroom. Do the lines you wait in ever behave in a LIFO fashion? Stop using the term "LIFO queue", it's nonsensical.
Jun
4
awarded  Popular Question
May
30
comment What's the proper way to model this real-world activity that seems to need circular references in OOP?
Contrary to the existing answers I think your design is poor and a proper fix should not result in circular references.
May
30
answered What's the proper way to model this real-world activity that seems to need circular references in OOP?
May
26
comment Why can't there be any implicit conversions?
@PieCrust: To be honest I would never expect len(100) to return 3. I would find it much more intuitive for it to calculate the number of bits (or bytes) in the representation of 100.
May
24
comment Can you implement “object-oriented” programming without the class keyword?
If you've ever seen WindowProc in the Windows API documentation, it's exactly the OOP dispatcher function you're trying to invent here, in C.
Apr
12
comment Ambiguity of seemingly clear method names in APIs
+1. Regarding your comment: returning the data is ideal, except that it's a huge performance hit to allocate a new buffer every time, so it's not done in practice (as you can tell in Stream).
Apr
12
comment Ambiguity of seemingly clear method names in APIs
@BenAaronson: I guess, but that's neither the real problem here nor can I think of better names. The problem still exists inside the other methods in MyComponent and in derived classes, doesn't it?
Apr
12
asked Ambiguity of seemingly clear method names in APIs
Apr
4
awarded  Notable Question
Mar
24
comment Do dynamic typed languages deserve all the criticism?
@PaulNathan: You're thinking too hard. The question was asking about dynamically typed languages, and this answer mentions Java as though it's dynamically typed.
Mar
24
comment Do dynamic typed languages deserve all the criticism?
@PaulNathan: Did you read the question?
Mar
24
comment Do dynamic typed languages deserve all the criticism?
I like your answer but Java isn't dynamically typed...
Mar
24
comment Method extraction vs underlying assumptions
+1 One thing that's important to note is that there is a cost to splitting up a big method into smaller chunks: it's typically not useful unless the preconditions and postconditions are more relaxed than they would have been originally, and you can end up having to pay the cost by re-doing checks that you would have otherwise already done. It's not a completely "free" refactoring process.
Mar
24
comment Method extraction vs underlying assumptions
Relevant: Is it always a best practice to write a function for anything that needs to repeat twice?
Mar
21
comment When is it a good idea to force garbage collection?
+1 for that paragraph as well. I find it shocking that people think a computer program written by someone else must necessarily understand the performance characteristics of their program better than themselves.
Mar
20
awarded  Curious
Mar
16
comment What is the reason of using an interface versus a generically constrained type
Interface methods are indirect calls, whereas type methods can be direct calls. So the latter can be faster than the former, and in the case of ref value type parameters, might actually modify the value type.