Reputation
789
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
4 11
Newest
 Yearling
Impact
~15k people reached

  • 0 posts edited
  • 0 helpful flags
  • 45 votes cast
Apr
16
revised Queue vs Threads
added 1 character in body
Apr
16
answered What is the best data structure to store 2 keys and 3 values?
Mar
10
revised Queue vs Threads
added 18 characters in body
Mar
9
revised Queue vs Threads
added 336 characters in body
Mar
9
answered Queue vs Threads
Feb
27
comment How to handle shutdown/startup of a Java application that relies on real time events?
Please also note that you will likely lost some of the events: anything between your clients and the server could fail. In order to keep as much information as possible, I would simply (redundantly and) persistently store each event as fast as possible after reception, and perform some computations "from time to time". In such a way, if your computing process/server/handler fails, you can always compute all derivated values again from your "history". Redundant events will then be handled by simply ignore them.
Feb
20
revised How to save tuplas values, to later search on it
Added a link to a comparison between thread safe alternatives.
Feb
20
comment How to save tuplas values, to later search on it
"I wouldn't even mention Hashtable in any context apart from history or uber-legacy code." The OP mentioned Hashtable, so I discussed it. Plus, by no mean not(A) => not(B) implies A => B. Also, Hashtable ensures thread safety, but in a suboptimal way. So it is definitively not a bad solution. I added a link in my answer for a detailed comparison between Hashtable, ConcurrentHashMap, and Collections.synchronizedMap.
Feb
19
revised How to save tuplas values, to later search on it
added 6 characters in body
Feb
19
answered How to save tuplas values, to later search on it
Jan
15
comment Why would I need `equals` if I have already `hashcode`?
Wow, my mistake. I was actually (erroneously) remembering Chapter 3 of Effective Java. So a Rational class must implement hashCode in such a way that two Rational objects representing the same value but having different numerators and denominators (and therefore having potentially a different behavior) have the same hash. OR two Rational objects representing the same value with different numerators and denumerators must not be equal. Right?
Jan
15
comment Why would I need `equals` if I have already `hashcode`?
In addition to the risk of collision or the impossibility to produce a decent hash, there is also the fact that two objects having different hashes may be logically equals, because some objects properties may be not relevant to determine this equality. So even if same hashes (and no collision) should implies equality, different hashes does not implies inequality.
Jan
5
comment Refactoring a long method which is based on large number of switch cases
The problem is that the ability to maintain the switch will decrease as the number of cases increases: you are getting a longer method each time a new option is inserted. Conversely, the method() body will have the same length and complexity, independently of the number of available options. And each option manages a single, isolated, and therefore more easily maintainable behavior. Plus, again, a switch places a option-based behavior in something that is not an option, but has or receive an option.
Jan
5
answered Refactoring a long method which is based on large number of switch cases
Jan
5
comment Refactoring a long method which is based on large number of switch cases
You also have to take into account the fact that enum+switch structures tend to make you option-based logic spread all over the code, instead of concentrate it in a single point. It's a violation of the open-closed principle.
Dec
15
answered How to find a subset of size k such that the minimum distance between values is maximum
Nov
17
revised implementing an extended interface on a concrete class
added 285 characters in body
Nov
17
answered implementing an extended interface on a concrete class
Nov
13
comment What is the best way to handle two very similar projects with Git?
@SlavaKnyazev Actually, this is used by Github for handling many repositories more efficiently: a blob is only stored once for all Github projects. This is particularly efficient for fork projects and typically common files such as license files.
Nov
12
comment What is the best way to handle two very similar projects with Git?
If you use different repositories, you could be interested in shared clones which allow you to share common objects and therefore spare disk spare.