1. -1
  1.  

  2. 4

    Funny that the good example in rule 4 violates rule 2 - don’t put the type name in variable names.

    The currencies_map should simply be currencies.

    You could also argue that it violates the “If there’s a need to return something empty in some failing case, it is recommended to raise an exception that can be cleanly caught.” rule.

    This is a whole lot better than returning some random “undefined” string. Now you have introduced special behaviour and you need to know that “undefined” is some magic constant. This is an anti-pattern by itself.

    It may be better to raise an exception if you ask for a currency that does not exist in the map. Which the default accessor does.

    1. 1

      “Classes that only hold data and do not contain any other functionality can not operate independently.”

      Explain why please. Why not?

    2. 1

      What’s wrong with returning a union type? Works for many languages, including python for the last 30 years.

      1. 1

        There is literally nothing new about this. There is even a book about them and linters check them for years now: The Little Book of Python Anti-Patterns