Reputation
2,975
Top tag
Next privilege 3,000 Rep.
Cast close & reopen votes
Badges
14 21
Newest
 Enlightened
Impact
~181k people reached

  • 0 posts edited
  • 0 helpful flags
  • 156 votes cast
Feb
5
comment When are enums NOT a code smell?
I would say enums aren't a code smell at all. Comparisons to enum constants are though. (e.g. if (type == Types.FOO) {...})
Feb
5
comment Word game algorithm
If letters can't be rearranged, it's probably more efficient to only store the new letter and its position rather than the entire successor word.
Feb
5
comment Word game algorithm
O Romeo, Romeo... Anyway, for an actual game I'd probably pre-calculate the word DAG in its entirety. Then I'd store just the edges of the graph, labelling them (L,i), where L is the letter being added to the previous word, and i the position where the letter goes.
Jan
28
comment Do common MVC frameworks violate the LSP and is there a MVC framework which does not?
It is also important to remember that LSP is about context and expectation. You can't look at a code in isolation and tell with a 100% certainty whether it violates LSP or not.
Jan
28
comment Do common MVC frameworks violate the LSP and is there a MVC framework which does not?
@David Packer No, you are not. You are introducing a new class and therefore a new API. The API of the Controller class hasn't changed, it's still the same. And if your class behaves sensibly, none of the pre- and postconditions of Controller will have been violated. What LSP says is that you are free to introduce any new functionality in a subtype, so long as clients who only care about the supertype can safely ignore it. So for example if you introduce an init() method, which must be called before the class is usable, that violates LSP.
Jan
25
comment Should we avoid language features that C++ has but Java doesn't to increase maintainability?
@PatriciaShanahan Never mind features, even variable/function declaration and naming idioms make a huge difference in readability.
Jan
25
comment Should we avoid language features that C++ has but Java doesn't to increase maintainability?
@NathanCooper It does happen occasionally, I certainly had to field such requests several times. But once I managed to explain why this is a terrible idea both technologically and financially, the resolution always was that the software will be rewritten from scratch to a better spec, feeding in the lessons learnt during several years of usage.
Jan
21
awarded  Enlightened
Jan
21
comment Is it a good practice to use List of Enums?
Actually in Java EnumSets are implemented as bit fields.
Jan
21
awarded  Nice Answer
Jan
20
comment what happens at Java interpreter level when IncompatibleClassChangeError is thrown?
It can have many different reasons, explained in detail here and here.
Jan
18
awarded  Yearling
Jan
16
comment Enum with a lot of boolean properties
@user949300 That's exactly what EnumSet does internally. In fact it has two implementations: the one for enums with 64 or fewer values stores the set as a long, the other one as an array of longs.
Jan
15
comment Enum with a lot of boolean properties
@Joffrey When you think about it, having ten booleans doesn't force them to give an answer either, at least not an answer they think about. The most likely scenario is that they'll just copy another page's definition or just let the IDE fill all parameters with false, then modify one or two (probably the wrong one, as it's so hard to keep track). There is no perfect protection from stupid, and there comes a point where you must trust your developers to do the right thing.
Jan
15
answered Enum with a lot of boolean properties
Jan
15
comment How to handle user created expressions in application
I've found that using an existing scripting language to deal with configuration like this is the cleanest solution. Easier than inventing your own config language, you don't need to worry about parsing and most importantly, there's lots of documentation and tutorials on the language that your users can turn to.
Jan
15
comment Why does the documentation on some languages say “equivalent to” rather than “is”?
This sort of thing happens all the time in Java too, as both runtime optimisations and intrinsified method calls can cause a different implementation to be run without warning (and hopefully without any noticeable effects to the calling code).
Dec
2
comment How does having too many instance variables lead to duplicate code?
Simply put: n boolean variables for example create an internal state space of 2^n. More often than not though your object does not have that many observable states, but because you crammed all that state into a single object, internally you still have to handle them all.
Dec
1
revised Using super keyword to access super class members
added 4 characters in body
Dec
1
answered Using super keyword to access super class members