1,925 reputation
715
bio website kdgregory.com
location
age
visits member for 4 years
seen yesterday

Feb
24
comment When to use a SortedMap interface?
You're expecting way too much from the type system. No matter how much you want to believe that types rigourously define behavior, it comes down to implementation by an ordinary human. In the case of Java interfaces, there's no pretense; the interface describes a contract, with luck that contract doesn't have too many corner cases, hopefully the people who implement classes based on that interface follow the contract without bugs, and the consumers of that interface use it in its intended manner.
Feb
19
comment Why html entity names for characters like ¥ € ¢ © ®
What if your <meta> tag lies, because your website admin doesn't know that you use UTF-8?
Feb
16
comment Using message queue systems - forcing synchronous processing
rabbitmq.com/tutorials/tutorial-six-php.html
Feb
2
comment Is a 1 < 10 comparison less expensive than 1 < 1000000?
Also, any actual implementation difference is going to be extremely architecture-specific, to the level of the micro-architecture. It's entirely possible that the microcode for Intel Sandy Bridge is different than that for Ivy Bridge, never mind that any arbitrary ARM chip is almost certainly different than an arbitrary Intel chip.
Feb
2
comment Is a 1 < 10 comparison less expensive than 1 < 1000000?
As edited, any difference in timing is almost certainly due to branch prediction, as @gnat said. However, this difference is likely to be infinitesimal, especially if measured in a high-level language running on a modern operating system. Are you actually seeing a difference, or is this a hypothetical question?
Jan
30
comment Is there any harm in using amazon AWS as a development environment?
I use an EC2 instance for development in my current project, because it provides a known environment: I can control exact versions of frameworks and installed software, and I can ensure that my development machine config exactly matches production config. And I ensure that the configuration for one project does not "pollute" my laptop going into a new project. As a side benefit, I think working on EC2 with a scripted install gets you into the habit of "throw the old one away" whenever you change configs, rather than attempting to maintain a single system (and not knowing what it runs).
Jan
30
comment Is there any harm in using amazon AWS as a development environment?
One additional bullet point: you will need to learn basic server security. If you expose your server to the open Internet, it will be pounded by crackerbots. Learn to use security groups to restrict access to specific IP addresses. And never enable password-based authentication or direct root login.
Jan
21
comment Determine exact coordinates for a map image?
I don't know why the closers chose "too broad," but in my opinion the question remains unclear. Even with your edit, I still don't know whether you're trying to place markers on an image that contains a blank map or something else. Your comment about knowing the lat/lon for an image is particularly strange: if you create the image, you should already know what it represents. I suggest a complete rewrite of the question, in which you paste pictures and description of what you want to do at each step. Also be very clear about what you already have and what you want to achieve.
Jan
20
comment Why sacrificing good software engineering practices is typically the first choice for software development projects assuming “good enough” quality
@David - or (3) say no. And yes, I've done it. And no, it never resulted in me being fired.
Jan
20
comment Scaling locks in high concurrency web apps
"This scenario" is actually many different scenarios, with many different solutions. From your description, it seems that your locks are long-lived, which requires completely different solutions than short-lived locks ("long-lived" for me is anything over a millisecond, it sounds like you're dealing with seconds or even minutes if you've turned to a database). To give a reasonable answer, we would need to know the actual use case that you're trying to solve.
Jan
18
comment Determine exact coordinates for a map image?
It's unclear what you're asking. If you want to plot lat/lon on a flat plane, then yes, projection is important. The standard "schoolroom" projection is Mercator, and the Wikipedia article gives you all the math you need.
Jan
18
comment Minimizing database requests for moves of a chess game?
If you somehow think that you can load all possible moves in one query -- or even store them in a database -- it ain't gonna happen.
Jan
18
comment Minimizing database requests for moves of a chess game?
Or are you simply looking for a way to uniquely identify each move (ie, the database key)? If that's the case, then you need to represent the state of the board. One approach would be to use a row-wise traversal that identifies each piece on the board, something like "A8BRB8BK...H1WR" (I combine piece name and location because that takes a maximum of 128 characters but will decrease as the game proceeds; you could also use a fixed-size format with just the piece names, taking 128 characters for each move).
Jan
18
comment Minimizing database requests for moves of a chess game?
What are you really trying to accomplish? The website that you linked maintains statistics about sequences of moves, and lets you navigate those moves. Given that navigation takes human-scale time, there's no reason to care about 40 database reads: the time they take is immaterial.
Jan
3
comment What does “business logic” actually mean if not “all non-3rd party code”?
If you order more than $50 you get free cheese-encrusted breadsticks.
Dec
30
comment What is different between the internal design of Java and C++ that lets C++ have multiple inheritance?
... which is why Java has distinct invokevirtual and invokeinterface operations (as well as several other forms of method invocation).
Dec
30
comment What is different between the internal design of Java and C++ that lets C++ have multiple inheritance?
@DVK - it's extremely difficult to give you an appropriate answer to this question. The trivial answer is that, because Java uses dynamic dispatch, there is nothing physically standing in the way of supporting multiple inheritance. However, it's unclear whether you understand how dynamic dispatch works (even though you mention v-tables), so a real answer would need to expand on how the compiler translates a method call into an indirect lookup. Or, at the other end, there are performance implications depending on the ordering of methods ...
Dec
30
comment What is different between the internal design of Java and C++ that lets C++ have multiple inheritance?
One could even say that Java is vtables all the way down.
Dec
26
comment Algorithm to merge two sorted arrays with minimum number of comparisons
You could create some adaptive algorithm that attempts to use a merge size > 1, but that isn't going to get you significant savings. A better solution is to map the source arrays into a form that is inexpensive to sort. This, however, depends on your actual situation (and neither of your examples would justify it).
Dec
24
comment What'd be better? To add one more local variable, or to call a method twice in general case?
@Doval - Yes IO is a side-effect. In my original edit I only had two points, but then thought that someone would be sure to call me out on volatile reads. That said, I think that it's important to understand and recognize the difference between what I'll call "active" and "passive" side-effects: the former are caused by your action, the latter are caused by external action. In my experience, most concurrency bugs are a result of the latter, not the former.