• Vilx- (unregistered)

    Frist! => Frist!

  • Industrial Automation Engineer (unregistered)

    This code warrants a trip to HR. Reason: purposefully inappropriate, abusive, and/or fraudulent behaviour. inappropriate: this code insults co-workers abusive: this code creates a hostile work environment, elicits aggression, breaks down morale. fraudulent: during the job application they have knowingly deceived the interviewer. they have never even thought about programming. ever.

  • (nodebb)

    If I'm not mistaken, these guys have done it: they became paid, professional programmers without knowing how to use greater than and less than operators.

  • (nodebb)

    TRWTF is the article also being embedded in the comment

  • (author) in reply to thosrtanner

    You mean the easy reader comment recreates information that could be expressed in a much more succinct manner? I wonder if that's related to the article in some way.

  • my name is missing (unregistered)

    If all you have is a hammer, everything looks like a thumb.

  • Jonathan Lydall (google) in reply to Mr. TA

    But the for loop is using one!

  • Brian (unregistered)

    Sadly, this is not the frist time I've seen a map that's really just an overwrought array. But it takes a special kind of brillance to do the same with the values.

  • DanK (unregistered) in reply to Jonathan Lydall

    That was copy-paste from a for-loop example they found on stackoverflow.

  • akozakie (unregistered) in reply to Remy Porter

    Even better and more fitting: it reuses something done once just because it's functionally sorta-kinda-similar, without caring whether it is in any way appropriate for the task.

  • NoLand (unregistered) in reply to thosrtanner

    thosrtanner (nodebb) 2021-03-11 TRWTF is the article also being embedded in the comment

    Sometimes, an article is already that comprehensible that the Easy Reader Version is just the same. So what do you do? Now, each article covers a range…

  • (nodebb)

    Let's not forget the unnecessary key = value = i; when they could have just done myMap.put(i, i);

  • Rob (unregistered)

    Let's ignore the fact that storing each value is unnecessary. Even then, the use of a Map with the keys and values always the same is unnecessary. Why not just use a Set? That could also greatly improve the lookup:

    return mySet.contains(input);
    

    Even with the Map, containsKey could improve this from O(n) to O(1). Guess they never heard of that (or even containsValue, which would do the same as this loop but without having to write the loop yourself).


    Now everybody that says that this could be done with only greater than and less than is missing one feature of this setup - it allows multiple ranges and values. There's nothing preventing me from calling addRange(0, 10), addValue(15) and addRange(20, 30). 11-14 and 16-19 should obviously not be included. You can't do that with just one simple comparison.

    However, even then there's a simple solution. With Java 8 or later: use a List<IntPredicate>, and add simple predicates like "i -> min <= i && i <= max" or "i -> i == value". With Java 7 or earlier: do the same with your custom interface and anonymous inner classes.

  • Jimmy (unregistered)

    "Wouldn't it be funny if, instead of just tracking the range's endpoints, they populated an array with all the possible values instead?"

    You mean like range() in Python 2?

Leave a comment on “A Range of Skills”

Log In or post as a guest

Replying to comment #:

« Return to Article