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

Apr
10
comment What is “Soft Coding”, really?
@ZeroOne: But for AUTHLDG-3C the ledger amount is actually a maximum. And for AUTHLDG-4D the appropriate ledger amount depends on the state. (Do you get the point yet? For this type of code, you want your code to reflect the business rules, not some attempted abstraction of the business rules, because there's no reason to expect the evolution of the business rules to line up with the abstractions you've adopted.)
Apr
10
comment What is “Soft Coding”, really?
@ZeroOne: But there may be yet other documents with different ledger amount thresholds.
Apr
10
comment What is “Soft Coding”, really?
@ZeroOne: Except that if the business rule changes to "Ledger of 500K or more requires AUTHLDG-1A and AUTHLDG-2B", it's very likely that the person who adds the attachDocument("AUTHLDG-2B"); line will fail to update the constant-name at the same time. In this case, I think the code is quite clear enough with neither a comment nor an explainer variable. (Though it might make sense to have a convention of indicating the appropriate section of the business requirements document via code comments. Under such a convention, a code comment that does that would be appropriate here.)
Apr
3
comment Business logic: Database vs code
@Kevin: Unless I'm missing something, Boris the Spider hasn't posted any answer here?
Apr
2
comment Business logic: Database vs code
@BoristheSpider: Although Kevin phrased his question in a general way, he raises a point that applies to this answer: the only specific form of DB-layer business logic that this answer mentions is stored procedures, but business logic can also take various other forms, such as views.
Mar
28
comment Should I add redundant code now just in case it may be needed in the future?
In your first paragraph, you forgot to mentioned the cost of maintaining that code over time, when it turns out that the feature that's actually needed is mutually exclusive with the feature that was added unnecessarily . . .
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.