Reputation
420
Top tag
Next privilege 500 Rep.
Access review queues
Badges
4 7
Newest
 Yearling
Impact
~5k people reached

Jan
24
comment When is it appropriate to make a separate function when there will only ever be a single call to said function?
@MartinSmith: DRY is relevant because it's implicit in the question. (The OP is asking: is there any point in splitting something out into a function when this won't help with DRY? And this answer is saying: yes, because DRY is just one of several reasons for splitting something out into a function.)
Jan
2
comment Is there a design pattern to remove the need to check for flags?
@LightnessRacesinOrbit: There's some truth in what you say, but it's perfectly reasonable to ask if there's a better way to structure one's code, and it's perfectly reasonable to invoke a design pattern to describe a proposed better structure. (Still, I agree that it's a bit of an XY problem to ask for a design pattern when what you want is a design, that may or may not strictly follow any well-known pattern.) Also, it's legitimate for "patterns" to affect your code slightly, in that if you're using a well-known pattern, it often makes sense to name your components accordingly.
Jan
1
comment How is defining that a method can be overridden a stronger commitment than defining that a method can be called?
@eigensheep: show and hide still exist, they're just @Deprecated. So the change doesn't break any code that merely invokes them. But if you've overridden them, your overrides will not be called by clients who migrate to the new 'setVisible'. (I've never used Swing, so I don't know how common it is to override those; but since it happened a long time ago, I imagine the reason that Deduplicator remembers it is that it bit him/her painfully.)
Dec
5
comment How is defining that a method can be overridden a stronger commitment than defining that a method can be called?
+1. I'm not sure why the other answer was accepted; it makes some interesting points, but it's definitely not the right answer to this question, in that it's definitely not what is meant by the quoted passage.
Nov
14
awarded  Yearling
Oct
9
comment Iterator pattern - why is it important to not expose the internal representation?
Human bodies are terrible software engineering; their codebase is not even remotely readable, let alone maintainable. Imagine that you had to add a simple feature, such as the ability to perceive X-rays. How would you go about it? How would you ensure that you didn't introduce any serious bugs at the same time?
Oct
9
comment Iterator pattern - why is it important to not expose the internal representation?
Real code pays the bills, yes. Good API design is how you ensure that you will continue to be able to generate real code. Crappy code stops paying for itself when a project becomes unmaintainable and it becomes impossible to fix bugs without creating new ones. (And anyway, this is a false dilemma. What good code requires is not time so much as backbone.)
Oct
9
comment Iterator pattern - why is it important to not expose the internal representation?
Re: "Or consider a development environment where you don't have time to make 'good APIs,' and need to use things immediately": If you find yourself in such an environment, and for some reason don't want to quit (or aren't sure if you do), I recommend the book Death March: The Complete Software Developer's Guide to Surviving 'Mission Impossible' Projects. It has excellent advice on the subject. (Also, I recommend changing your mind about not quitting.)
Oct
8
comment Does context (like as an argument in a function) allow for numbers in code that aren't magic numbers?
Re: "For example, a week has seven days everywhere around the world, so there is no point in having a DAYS_PER_WEEK constant": That doesn't necessarily follow. Using 'DAYS_PER_WEEK' instead of '7' doesn't just tell you that 7 is the number of days in a week, it also tells you that this is the relevant fact about 7. (This is especially an issue if there are other vaguenesses in the surrounding code. event.postpone(2 * 7) is inscrutable; event.postpone(2 * DAYS_PER_WEEK) is infinitely better.)
Sep
18
revised Should `setX(Object o)` methods perform deep or shallow copies of objects?
fixed unbalanced parentheses
Jul
5
comment What is the difference between function() and function(void)?
@KeithThompson: Thanks. :-)
Jul
5
comment What is the difference between function() and function(void)?
@KeithThompson: This question, and this answer, are talking about predeclarations, not function definitions.
Jul
4
awarded  Civic Duty
Jul
3
comment Is testable code better code?
@anaximander: To clarify: by "test" you mean "unit tests", right? Because the purpose of testing overall is quality, and making sure our code actually does what we promised it would.
Jun
20
comment Packaging structure of Java collections (java.util) - why does Iterable sit in java.lang?
My point was not that it's convenient, but that the language proper now depends on it. (Note that, aside from the dependency of Iterable on Iterator , the java.lang package does not generally depend on classes in java.util.)
Jun
20
comment Packaging structure of Java collections (java.util) - why does Iterable sit in java.lang?
+1. I think, though, that Iterator should ideally also be in java.lang, since Iterable is. Of course, it has to be in java.util for backward-compatibility reasons (it had been introduced in the JDK long before the "foreach" construct gave it a role in the language proper).
Jun
12
comment What is the difference between function() and function(void)?
Re: "This is usually used to implement a function which can take a variable number of arguments": Are you sure about this? I don't think I've ever seen a program that used explicit parameter-lists for forward-declarations of non-variadic functions and () for those of variadic ones. Do you have an example of a program that uses this convention?
May
29
comment Is the use of one-letter variables encouraged?
@Nelson: This question, and this answer, are about Java. Obviously different languages can have somewhat different considerations. (JavaScript is not the same language as Java.)
Apr
27
awarded  Nice Answer
Apr
25
answered If Scala runs on the JVM, how can Scala do things that Java seemingly cannot?