Reputation
1,803
Top tag
Next privilege 2,000 Rep.
Edit questions and answers
Badges
4 10
Newest
 Commentator
Impact
~53k people reached

  • 0 posts edited
  • 0 helpful flags
  • 6 votes cast
Jun
8
comment Clean Code comments vs class documentation
... describes the purpose of the following lines. I have complied with the rule to not write comments. Is this better? I would say absolutely not, it is far worse, because the reader may be confused into thinking that this variable actually does something, rather than just being a name added to the code to act as a fake comment. That is very similar to the suggestion of writing a dummy subroutine whose only purpose is to provide a name that serves as a comment.
Jun
8
comment Clean Code comments vs class documentation
@EricKing So if you can express "meaning" and "descriptiveness" in code rather than comments, that's a good thing. I'd agree with that in principle. But the idea of moving code to a function just so you can give the function a name rather than writing a comment is applying this rule in a pedantic, irrational manner. The only gain in using the function name is that you comply with this rule. How about if instead of writing the comment, I added a line of code that said, "bool adjust_for_leap_year = true;". Then I never use this variable again. Now I don't need the comment, because the "code" ...
Jun
8
comment Clean Code comments vs class documentation
@phresnel If a function is only called from one place, and you only created that function so that the name could serve as "self-documentation", then the fact that the compiler can enforce parameter types is irrelevant. The only reason the function exists is to have a name, and while the compiler can enforce that the name in caller and callee match, it can't enforce that the name accurately describes what the function does, which is the only reason why this function exists. So the one thing that matters, the compiler CAN'T enforce.
Jun
5
comment Clean Code comments vs class documentation
@Ericking Hmm, saying that instead of writing an "adjust for leap years" comment you should move the two lines of code to a function and name it "AdjustForLeapYears" sounds to me like you are just using a function name as a comment. How is this better than writing a comment, other than that it conforms to an arbitrary rule that you shouldn't use comments? That's like saying that "goto"'s are bad ... so I wrote "#define jump goto" so now I can write "jump" instead of "goto" and the problem is solved! :-)
Apr
17
comment Why do I need to map arguments to instance variables?
I don't see how it throws away type safety. Most of the rest of what you said I agree with and conceded above. It works in situations where many constraints apply, i.e. none of the above issues come up. But that's actually a pretty large number of cases that I come across. If an object calls for a long parameter list in a constructor, odds are that most of that data is of the in-and-out type, i.e. the object is a place to hold bunches of data about a customer or a product or whatever, and most of that data doesn't affect the logic, it just gets read, stored, and updated.
Apr
6
comment Why are people making tables with divs?
@DavidW Exacty. And I'd add: the design of HTML, CSS, and JavaScript came about through a series of fits and starts and divergent goals and changes of mind. Just look at the number of deprecated tag attributes in HTML 5! If the thing had been cleanly designed from the beginning, maybe some of these issues would just never have come up. As is, we have to work with what we have. (PS I don't say this to demean the people who invented these tools. There had to be some real geniuses in there. That's just how life is. Nobody knew where it was going when is started.)
Apr
2
comment Enforcing open source software license
@MichaelT True. Such a compare would only work if both people used the same compiler with the same options set. I was being too simple-minded. So I suppose it MIGHT work, if the test passed they are from the same source, but there would be lots of false negatives.
Apr
1
comment Enforcing open source software license
Hmm, I wonder if anyone has ever built a software product to examine two sets of binary code to try to determine if they have sections that were compiled from the same source? Obviously even a minor change would make all the addresses different, but if a program had all the same opcodes in the same order, and only the addresses were different, that would be awfully suspicious. But maybe I'm being too simple-minded there.
Apr
1
comment Enforcing open source software license
Identical text strings or other constants in the code would also be a clue. Of course the fact that two programs both have the message "Error - retry" would prove nothing. But as messages get longer, we'd expect there to be differences in wording, even if the basic idea is the same.
Apr
1
comment Why are people making tables with divs?
... "because it's the rule". I have had a number of conversations with such people over the years, on this particular issue and on many others. People who refuse to even discuss the pros and cons of a rule, because it's the rule, end of discussion.
Apr
1
comment Why are people making tables with divs?
Hmm, seems to me that I said something like: "Someone sees a problem and proposes a rule to prevent it. Others see the value of this rule. Then they insist on blind devotion to this rule without regard to the original problem it was supposed to solve and/or regardless of what other problems it creates." I don't deny that there is reasonable thinking behind the rule. I just don't agree with the conclusion. Surely I can say, "You have a good point there, but nevertheless I disagree." And surely you do not deny that there are people who don't understand the pros and cons and say ...
Jan
30
comment Leaving intentional bugs in code for testers to find
I'm guessing that Patton meant that you should have rigorous training and field exercises during peace time. The analogy would be to have rigorous classes in IT school or post-degree training. I'm pretty sure Patton didn't mean that officers should be instructed to shoot at their own troops from behind to keep the troops on their toes!
Jan
28
comment Leaving intentional bugs in code for testers to find
"incentivized to find the bugs you know are there" Excellent point. If an organization is doing this, it likely means that someone is breathing down the QA folks necks to make sure they find the planted bugs, so that will be their top priority. What if they get together and figure out, say, "Hey the planted bugs are almost always that it fails to save one field on an edit screen with a bunch of data" (or whatever). Then they'll spend an inordinate amount of time looking for that one type of bug, and increase the chance that they'll miss other types of bugs.
Jan
25
comment Throw exception or let code fail
@MarcvanLeeuwen RE the potential race condition: True. I find that a more persuasive argument.
Jan
25
comment Throw exception or let code fail
@MarcvanLeeuwen Why is efficiency not important in the case where there is an error? I don't think that's necessarily true at all. If in the error case the program will display an error message to the user and stop, while in the success case it does a bunch of additional work, it might be relatively less important. But at this level you don't know that. Maybe when there's an error the caller selects a different NAME and tries again, and keeps trying different names until if finds one that's a success -- for example in a function that's trying to assign a unique name.
Jan
23
comment What is negative code?
@Synetech Sure ... to a point. If by replacing clear, readable code with something hopelessly cryptic I shave 0.01 seconds off the time it takes the screen to respond to a button press, almost certainly not worth it. If an easier to read function means that a screen that used to return in half a second now takes half an hour, no. But I agree that most of the time, readability and maintainability are more important than speed, because in real life, speed gains are usually -- not always, but usually -- trivial.
Dec
31
comment What is negative code?
@Synetech Sure, brevity achieved by using some obscure construct is not a plus. But brevity achieved by eliminating redundant code is a huge plus. Brevity achieved by eliminating code that is never executed is a big plus too. Brevity achieved by simplifying the algorithm requires case by case analysis: If by simplifying it you have made it easier to understand but take longer to run, that could go either way.
Dec
31
comment What is negative code?
A more serious analogy would be that measuring software productivity by lines of code is like measuring progress on an auto repair job by counting the number of grease rags used. This could be accurate to an extent: the more work the mechanic does, the more grease rags he'll use. But it counts mistakes and wasted effort as much as effort that actually leads to a goal, and a big mistake -- like accidentally breaking an oil line and having to clean up a huge mess -- gets counted as major progress when it's really the opposite.
Aug
26
comment What is negative code?
@Nav: Reminds me of a similar story that begins the same way. Then the coach throws a ball in the air, swings and misses. He throws it in the air again, swings and misses. He throws it in the air a third time, swings and misses. Then he says to the team, "See, THAT'S how you should be pitching!" (I have no idea what this story might have to do with software development.)