196 reputation
6
bio website
location Redmond, WA
age
visits member for 3 years, 6 months
seen 2 days ago

Jan
5
awarded  Citizen Patrol
Dec
15
comment Using audit trail as time machine?
Um, no, don't use BETWEEN, use an exclusive upper-bound. What you're doing will include 2 rows in some cases. end is best thought of conceptually as null, which it should probably be stored as (although this would require additional checks). Note that ending values are always derived values.
Dec
8
comment Why does the Java collections APIs not have a last method?
When it comes to List, generally you're going to use an Iterator (either explicitly, or implicitly via things like for-each) to read through elements - it's trivial to make these reference infinite/looping elements. Having an 'infinite' list doesn't mean you're actually storing that much data, just that there's an element accessible, somehow. Consider a list containing the digits of 1 / 3 (perhaps as part of a Natural/Rational number library). There is no last digit - it's trivial to say what each digit will be - 3 - but you can neither store them individually, nor get a last.
Dec
8
comment Why does the Java collections APIs not have a last method?
I didn't downvote, but the problem is that your idea is an increase in the surface area of an API (which can lead to bloat). Unlike some other languages, List in Java is an interface, which means you have to be really careful about what the default behaviour is; counting 'backwards' prevents the use of things like infinite lists (which you could use to hold random numbers, say).... Also, the fact that this is an old question (and potentially subjective) might have factored into it.
Dec
7
comment Why does the Java collections APIs not have a last method?
Another reason to not support something like a last() method - infinite lists.
Nov
28
comment What level/format of access should be given to a client to the issue tracking system?
@AndreyRybak - it doesn't matter, the problem is that you have any tickets. If you measure it, somebody will judge based on it. Actually, no, the problem is that you have a ticket-tracking system; people will make judgments if you have no tickets. This transcends the bounds of reason - it's why some managers say things like "you sold a lifetime-widget to everybody in town this year, can you maybe sell everyone two next year?".
Nov
25
comment Should I use relational or noSQL databases for this problem
Note that if you store address from multiple countries, (physical) addresses will vary hugely in format anyways...
Nov
24
comment calculating the average of a value over a month
In SQL, conceptually what you want is a view - that is, you don't store the average, you store a query that calcs the value on-the-fly for you. Most RDBMSs provide ways to "materialize" these (store the computed value) if necessary. If you do store it (say, to "apply" it as a bank transaction), you need to explicitly call out the timeframe the calculation was performed over (lastAccessed is good audit information, but a terrible way to keep track of where you are). Finally, understand that averaging amounts in small groups will give different results than an average as one large group.
Nov
5
comment Using public final rather than private getters
@kritzikratzi - The problem is that you can't guarantee that your code won't run into idiots. At some point it will (which might even end up being oneself!), and the surprise could be a huge problem.
Nov
4
comment How to Safely Sell Source Code?
As usual: Technology (or just general processes) can't solve people problems. It can shift it to someone else, it can spread it to multiple people. But it can't actually solve it for you (this is a lie that we as technology people often whisper to ourselves, never mind our customers - and boy is it a seductive one).
Aug
19
comment How to change the state of a singleton in runtime
Initialization of the file link needs to be one of the first things your app does - otherwise you may end up calling log before there's an output file (a good library probably has a built-in buffer or at least a default destination file). If you're building a GUI app, you can probably do it before the launch of the UI via the Swing threads. Most servers come with the logging built-in, so it's not something you have to worry about.
Aug
19
comment How to change the state of a singleton in runtime
synchronized, while it will make things thread-safe, is likely to slow logging significantly (waiting for other threads). Depending on the design, you might even get into some form of deadlock, which would be extremely painful. Besides which, it wouldn't actually protect you from the biggest issue - calling log before setFile.
Aug
8
comment How to make sure media are used only on authorised sites?
The moment you serve the video, people can record it (you're providing them the data feed). There's ways to make this more difficult (isn't there some media encryption proposed for HTML5?), but there's too many ways to "recover" the data on a PC. You're trying to create your own DRM library/scheme/deployment, whereas the big name entertainment companies have spent millions (or billions) of dollars and failed in the long term (and generally just annoyed legitimate users). There's likely a library for baseline protection, but you can't stop determined people.
Aug
7
comment Eliminate duplicate code in nested IFs without creating a function
... why do you want to avoid a function? That's one of the things they're meant to do - keep you from writing the same thing multiple times. As the accepted answer shows it can be mitigated here, but the fact that you're avoiding a reasonable tool is somewhat troubling.
Jul
3
comment Why does C# have much more features than Java?
Note that Java probably has a greater selection of 3rd party libraries, likely by an order of magnitude.
Jun
27
comment Algorithm for percentage without knowing total number
After line 1 gets 6 calls, give line 2 4 calls. That is, don't care about the actual total count, care about the distribution over the "period" (10, in this case) that you do know. Obviously you can do stuff like alternate lines except the last value, so there isn't a strict wait necessary either. If there's some sort of queue, do the percentage based on current rows in the queue.
Jun
24
comment C# server side application 100 GB dataset + Garbage Collection
I'd put it in a DB, too. For that matter, there are some in-memory dbs, dunno if they could handle something that size though.
May
23
comment Origins of code indentation
Barring cases where indentation is used to change the semantic meaning of code (that is, where changing indentation will put it in loops or as part of an if, a la F#), indentation isn't really a language feature, it's an IDE feature (and a bit in the compiler, to ignore leading spaces). @Jack's right - originally programs were punched on cards, and indentation literally didn't exist in the storage (and perhaps shouldn't now, either). Columnar RPG doesn't use indentation (and you only have ~20 characters free per line anyways), but the IDE can "soft" indent the code for you.
May
23
comment Origins of code indentation
I don't think the quoted text actually supports the use/existence of indentation. That's support for sectioning code. Java uses brackets ({}) to delimit blocks, and you can define nested functions, but that doesn't tell me anything about whether the code is actually indented.
May
23
comment What's the copyright status of boilerplate code?
The fewer lines of code needed to complete a task, the likelier that different original implementations will be the same. If asked to sum all elements in an array, pretty much everybody is going to use a loop with an externally defined variable to hold the running total. There's two major directions to take a factorial function. The code submitted for things like Code Chef might be interesting to examine here - for all distinct (correct!) results, run a diff.