Ad
  • Custom User Avatar

    I disagree this being a best practice. It is clever and looks simple. Sure. But it is also not maintainable. As soon as point boundaries change, you have to rewrite the whole logic.

  • Custom User Avatar

    Looks clever, but this code is not easy to maintain. In case points change, and boundaries are no longer divisable by 10, this whole approach has to be rewritten instead of just updating the points.

  • Custom User Avatar

    I don't think nesting ternaries is a good practice. It makes code harder to read.

    I believe a more verbose and a less "cool" solution with a series of ifs would be more dev friendly.

  • Custom User Avatar

    Wouldn't this be an incorrect solution as it removes more than what was requested? (spaces vs all whitespaces)

  • Custom User Avatar

    Wait until you see all of my code using "var" wherever possible :)

  • Custom User Avatar

    using iter() instead of into_iter() will degrade performance

    This is really weird.

    Isn't into_iter giving you a copy, while iter giving you a reference? Why is making a copy faster?

  • Custom User Avatar

    Overriding the prototype is definitely not a good practice.

    But other than that, this code is simple and that is a good thing.

    Sure, it won't be optimal for running anagramm checks for millions of items, but that was not a requirement. Usually if something has to handle big data you know either because it is obvious from the context, or you are told that.

    In this case premature optimization would only made the code more complex and thus harder to read and understand. And that can be bad.

  • Custom User Avatar

    The speed of sort is irrelevant for an array of a couple of items and only a handful of invocations. Readability and maintainability is way more important for such cases.