| bio | website | |
|---|---|---|
| location | Chicago, IL | |
| age | 25 | |
| visits | member for | 1 year, 11 months |
| seen | 3 hours ago | |
| stats | profile views | 138 |
|
14h |
comment |
In languages that don't allow underscores in integer constants, is it a good practice to create a constant for 1 billion? @MathewFoscarini Actually, no, in this context it's not. If it were, a constant named NANOSECONDS is meaningless as you can't tell what it's supposed to apply to. Likewise, NANOSECONDS_PER_MICROSECOND is a similar valid constant that makes sense. |
|
May 20 |
comment |
Is Maven Convention over Configuration? -1; did you do any research yourself? I did one google search and found this, despite not even knowing what Maven is: Please try to conform to this structure as much as possible; however, if you can't these settings can be overridden via the project descriptor. |
|
May 19 |
comment |
Production or Custom Test Data for Unit Testing? If the refactored code had been released without the migration that fixed those problems, lots of users would have lost some of their saved data. But at the same time, it was too massive for regular automated testing, so I couldn't use it in my unit tests. |
|
May 19 |
comment |
Production or Custom Test Data for Unit Testing? +1, I agree and with experience to this effect: When I underwent a month-long refactoring project for a messy piece of code that was generating lots of bugs (with hacks upon hacks), I had unit tests in place with test data that ran often, which told me almost immediately if I made a mistake somewhere. About midway through, I started copying live production data, and discovered unexpected inconsistencies in the database that the bad code had created (that other code being refactored away had worked around). |
|
May 16 |
comment |
f(n) output of universal program Is this a homework problem? |
|
May 15 |
comment |
How to genericize foreign key references in table? Django can do it automatically through concrete model inheritance. The field names would be different, but it looks like your example is otherwise set up identically to how Django does it on the database. (Django also has abstract model inheritance, which would just copy the fields from Likable to its children, so a Foreign Key isn't allowed) |
|
May 15 |
comment |
php OOP - cant change value from outside class By the way, questions that involve a specific problem (especially questions like "why doesn't this code work?") are on topic on StackOverflow, but not here (And you'd've likely gotten an answer within 10 minutes given how active that site is). Programmers.SE is geared more towards conceptual questions. Hopefully a mod will come around to migrate this, instead of just closing it... |
|
May 7 |
comment |
How to unit test method that returns a collection while avoiding logic in the test @AnthonyPegram Sets are unordered - Frob may sometimes be 3rd, may sometimes be 2nd. You can't rely on it, making a loop (or language feature like Python's in) necessary, if the test is "Frob was successfully added to an existing collection". |
|
May 7 |
comment |
How should I create lo-fi (non-interactive) UI prototypes? +1 as well, it doesn't look nearly as fancy as Balsamiq, but the freedom more than makes up for it - no searching for a widget or being limited by what that program has available. |
|
May 7 |
comment |
Is MVC just the SEO of PHP programming? ...SEO? "Search Engine Optimization"? |
|
May 6 |
comment |
Retrieving maximum value from a range in unsorted array Granted, at the time of posting this answer, the question did not include the edit confirming that he'll be doing many queries over the same data. |
|
May 6 |
comment |
Retrieving maximum value from a range in unsorted array Switching my downvote to an upvote - your edit makes it clear why the simple solution isn't necessarily sufficient. As it was before (implying a single query), just about any preprocessing would've more than negated efficiency gains. |
|
May 6 |
comment |
Getting practicality of PHP from Ruby or Python Granted, it looks kinda like you just typed in something semi-random - why is there an object as the key of the dict? |
|
May 6 |
comment |
Getting practicality of PHP from Ruby or Python @Melllvar PHP is pretty close - without knowing what that outer function is, nor what postkey is: posts = getPostsForListOfPostIDs(array_map(function(postkey) { return postkey.hex; }, array_keys(timed_posts)), 3) |
|
May 6 |
comment |
Retrieving maximum value from a range in unsorted array @kevincline It's not just restating - it's also saying "Yes, you already have the best algorithm for this task", with a minor improvement (jump to start, stop at end). And I agree, this is the best for a one-time lookup. @ThijsvanDien's answer is only better if the lookup is going to happen multiple times, since it takes longer to set up initially. |
|
May 5 |
comment |
OOP principles and method names I'd got for on_punch() instead of on_punched(), it sounds better and implies immediate reaction. |
|
May 4 |
comment |
Retrieving maximum value from a range in unsorted array Otherwise, +1 as I find this rather inventive |
|
May 4 |
comment |
Retrieving maximum value from a range in unsorted array For this to work, there's information missing from your example tree: Each internal node must have both the maximum, and the total number of child nodes it has. Otherwise the search has no way of knowing that (for example) it doesn't have to look at all the children of 78 (and skip the 2), because for all it knows index 6 is in that subtree. |
|
May 4 |
comment |
Please tell me I'm not alone (can't program on paper) Probably because if you can install what you want, it means you have access to the internet. Which means you can just Google the answer. |
|
May 4 |
comment |
Retrieving maximum value from a range in unsorted array I can't imagine this being any faster than a plain O(n) search of the array, as described in tarun_telang's answer. First instinct is that O(log n + k) is faster than O(n), but the O(log n + k) is just retrieval of the sub-array - equivalent to O(1) array access given the start and end points. You would still need to traverse it to find the maximum. |