Reputation
4,625
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
10 25
Newest
 Nice Answer
Impact
~176k people reached

  • 0 posts edited
  • 5 helpful flags
  • 141 votes cast
May
6
comment Is renaming an 'alias' for moving?
@BanksySan - How do you distinguish between "rename" and "move"? (They're interchangeable words on many systems.)
May
4
comment Have any C compilers ever *defined* `unsigned short x=-3; x*=x;` to yield anything other than 9
@supercat - I'm done. I strongly suggest you read the standard. If your compiler vendor isn't compliant, get another compiler vendor.
May
4
comment Have any C compilers ever *defined* `unsigned short x=-3; x*=x;` to yield anything other than 9
@supercat - You are barking up the wrong tree. Early in the days of C, there were lots of compilers that didn't comply with the defacto standard of the time, K&R C. This hindered portability. Every program was sprinkled with #if (defined THIS_COMPUTER && THIS_COMPUTER) ... #elsif ... The purpose of a standard is to eliminate some of that nonsense. Even C90 specifies that unsigned integers use modular arithmetic. So long as k*k is less than n+1, (((n+1)-k)*((n+1)-k)) % (n+1) == k*k. It's basic math.
May
4
comment Have any C compilers ever *defined* `unsigned short x=-3; x*=x;` to yield anything other than 9
@supercat - I do remember that some dropped core at the drop of a hat. I haven't run into a C compiler that doesn't comply with ANSI C (C89/C90) for at 15 or 20 years, so you are asking me to reach way back.
May
3
comment Have any C compilers ever *defined* `unsigned short x=-3; x*=x;` to yield anything other than 9
@supercat - Ever? Of course. The mid 1970s to the mid 1990s was the age of the minicomputers. There were lots of minicomputer manufacturers; almost all of them are now gone. Lots of them had lousy compilers, goofy architectures. (For example, middle-endian computers). You didn't overflow, signed or unsigned, in those days if you wanted your code to be portable. Nowadays, a compiler that is not at a minimum ISO/IEC 9899:1990-compliant is a completely broken beast from a previous millennium. Even in that 25 year old version of the standard, it's very clear how unsigned integers work.
Apr
27
comment Is it always a good idea to divide large classes into smaller ones?
Is it always a good idea -- It's a good idea not to use "always". There are instead rules of thumb to which one should always pay attention, but don't get carried away. Even the much maligned goto has it's place.
Apr
6
comment What is the difference in memory between a variable assigned to null and one not assigned
@user61852 - That a reference not explicitly assigned a value will have the value null is true for class members, but not necessarily for local variables. If you are compiling your code with debug enabled, the compiler will almost certainly initialized your uninitialized non-primitive local variables to null. This greatly simplifies the development of the Java debugger. But what if you compile with debug disabled? Now that initialization is unnecessary extra work. What's in that memory is irrelevant because it is known that the memory will contain a valid value on first use.
Apr
6
comment What is the difference in memory between a variable assigned to null and one not assigned
Local variables do not need to be given an initial value. They need to be assigned a value prior to initial use. Whether the memory associated with that variable is given an explicit initial value, even in the case of a declaration with no assignment, is an implementation detail. The memory exists (that's how stacks work), but that memory space could be left filled with whatever happened to be in that memory prior to adjusting the stack.
Apr
6
comment What is the difference in memory between a variable assigned to null and one not assigned
@Snowman - Since it's illegal to use a local prior before it's assigned a value, whether an uninitialized local variables is given an initial value is an implementation detail.
Apr
6
answered What is the difference in memory between a variable assigned to null and one not assigned
Feb
11
comment How do you check that code has been covered automatically?
I am not the down voter. I suspect the downvote was because of your first sentence. Code coverage most certainly can be checked automatically. Perhaps you should change that sentence. The issue at hand is whether the results of that automated code coverage testing should in turn be used in an automated way, for example, in a git hook.
Feb
11
answered How do you check that code has been covered automatically?
Feb
4
comment Leaving intentional bugs in code for testers to find
What happens if an intentionally introduced bug covers up another bug the testers could have found had that intentional bug not been introduced? For example, suppose a chunk of code has a fencepost problem and that the development team is unaware of this bug. A programmer decides to insert an intentional fencepost error at that spot. Now the code has a double fencepost error. Suppose the testers detect the error, but don't see that it's a double fencepost error. Congrats! The testers found an introduced bug. The original code will be restored to contain the original fencepost error. Oops!
Jan
30
awarded  Nice Answer
Jan
17
comment Is it always a best practice to write a function for anything that needs to repeat twice?
+1 just for It often makes sense to create a function for something that's only executed once. I was once asked how to design tests for a function that modeled the behavior of a rocket engine. The cyclomatic complexity of that function was in the 90s, and it wasn't a switch statement with 90 some cases (ugly, but testable). It instead was a convoluted mess written by engineers and was utterly untestable. My response was just that, that it was untestable and needed to be rewritten. They followed my advice!
Oct
5
reviewed Reject Why do some projects have getters and setters for public instance variables?
Oct
5
comment When writing object-oriented code, should I always be following a design pattern?
As a secular programmer, about all I can say is "OMG, this answer is fantastic!" (as are the comments). Telastyn, Cerad, and tobyink, you three came this close to owing me a new computer monitor. It's a good thing my mouth was empty of liquids when I read this answer and the comments.
Sep
30
comment Derive subset with sum between two values
Solutions to the knapsack problem inevitably use what you call "guess and check".
Sep
30
comment Derive subset with sum between two values
Re Is there an algorithm to get the desired subset without using guess and check? Let M be the number of questions whose ranking is between 0.65 and 0.75. The answer to your question is yes if M>N. Just randomly choose N of those M questions. Otherwise, the answer is no.
Sep
30
comment Derive subset with sum between two values
What does that even mean, Preston? You have not fully specified the problem.