Skip to main content
15 events
when toggle format what by license comment
Dec 23, 2013 at 3:21 comment added Ampt @Daniel good eye. Fixed
Dec 23, 2013 at 3:21 history edited Ampt CC BY-SA 3.0
Fixed float division errors
Dec 22, 2013 at 22:10 history bounty awarded CommunityBot
Dec 22, 2013 at 20:28 comment added Daniel Lubarov Your Java code has some integer division where you want float division.
Nov 26, 2013 at 18:29 comment added Jimmy Hoffa @mattnz we are also extremely good at fearing it disproportionately.
Nov 26, 2013 at 3:05 comment added mattnz My point is that every proposed solution (your included) to the complexity faced by the OP is over simplified. By the time the proposal does what the OP requires (which we do not know accurately), including edge cases, it is likely to be no simpler than the original. We are so good in this industry at trivializing the last little bit.......
Nov 26, 2013 at 0:29 comment added user53019 @mattnz - 1) OP never specifies that in their example and may not care. How do you know the assumptions are invalid? 2) The general method would still work, potentially requiring a more complicated regex. 3) The point of the answer is to provide a conceptual route to resolving the cyclomatic complexity, and not necessarily a specific, compilable answer. 4) while this answer ignores the broader aspect of "does the complexity matter", it indirectly answers the issue by showing an alternative form for the code.
Nov 26, 2013 at 0:15 comment added mattnz So both you code snippets work with string "1.23E+2ms"
Nov 26, 2013 at 0:02 comment added user53019 @mattnz - have another look at the variables names within the examples provided. It's clear that the OP is receiving a time unit as a string and then needs to convert it to another type of time unit. So the examples provided in this answer pertain directly to the OP's domain. Ignoring that aspect, the answer still provides a generic approach that could be used for a different domain. This answer solves the problem that was presented not the problem that may have been presented.
Nov 25, 2013 at 23:16 comment added mattnz Neither of these answers can be considered to provide the same solution as the Original program as they rely on assumptions that may not be valid. Java Code: How are you certain the only thing the methods do is apply a multiplier? Python Code: How are you certain the string is not allowed to contain leading (or mid point) characters other than digits (E.g. "123.456s").
Nov 25, 2013 at 22:34 comment added user40980 @FrustratedWithFormsDesigner they may, but in the scope of that method, its just returning a long and the instantiated object falls out of scope. As an aside, this has the side effect of if this code is called more frequently, the number of frequently used, short lived objects with no state is cut down.
Nov 25, 2013 at 22:22 comment added FrustratedWithFormsDesigner Yes, mapping the strings to a conversion factor would be a much simpler solution. If they don't need the objects then they should get rid of them, but I can't see the rest of the program, so maybe they objects are used more as objects somewhere else... ?
Nov 25, 2013 at 22:13 history edited Jimmy Hoffa CC BY-SA 3.0
Simpler. Now it can be upvoted. :P
Nov 25, 2013 at 21:52 history edited Ampt CC BY-SA 3.0
Credit where Credit is due
Nov 25, 2013 at 21:26 history answered Ampt CC BY-SA 3.0