user avatar
TestDriven.io
@testdrivenio
Teaching practical programming through real-world applications. Tweets by @MikeHerman and @JanGiacomelli.
Denver, CO
Joined December 2017
  • user avatar
    Python Clean Code Tip: Use how and when to use decorators ๐Ÿ‘‡
  • user avatar
    Python clean code tip: Use enums to group related constants ๐Ÿ‘‡
  • user avatar
    Python Clean Code Tip: Check the quality of your code inside your CI pipeline Use: - black - code formatting - isort - optimize imports - bandit - check for security vulnerabilities - safety - check for security vulnerabilities of dependencies Github Actions Example ๐Ÿ‘‡
  • user avatar
    Python Clean Code Tip: Avoid using too many attributes on a single object. Try to cluster them to improve cohesion, reduce coupling, and improve readability ๐Ÿ‘‡
  • user avatar
    Python Clean Code Tip: Use dataclasses when only storing attributes inside your class instances to reduce the amount of boilerplate code ๐Ÿ‘‡
  • user avatar
    Python tip: To generate a random password you should use the secrets module For example, you can generate a random password of length 21 containing letters, number, and special characters๐Ÿ‘‡
  • user avatar
    Python Clean Code Tip: Don't use flags in functions Flags are variables passed to functions, which the function uses to determine its behavior. They are considered bad because functions should only perform one task. -> split your function into smaller functions.
  • user avatar
    Python Clean Code Tip: Check the quality of your code inside your CI pipeline. - flake8 - style guide enforcer - black - code formatting - isort - optimize imports - bandit - check for security vulnerabilities - safety - check for security vulnerabilities of dependencies ๐Ÿ‘‡
  • user avatar
    Python Clean Code Tip: Use a list comprehension to filter lists instead of for loop ๐Ÿ‘‡
  • user avatar
    Python Clean Code Tip: Avoid using too many attributes on a single object. Try to cluster them to improve cohesion, reduce coupling, and improve readability ๐Ÿ‘‡
  • user avatar
    Python Clean Code Tip: Keep your arguments at a minimum Ideally, your functions should only have one to two arguments. If you need to provide more arguments to the function, you can create a config object which you pass to the function or split it into multiple functions.
  • user avatar
    Python clean code tip: Use a dictionary to remove duplicates from a list and maintain order ๐Ÿ‘‡
  • user avatar
    Python Clean Code Tip: Avoid setting attributes of your objects outside of the constructor. Instead, implement methods that map to real-world concepts. Why? To ensure attributes exist and are easily discoverable. ๐Ÿ‘‡
  • user avatar
    Python clean code tip: Use dependency injection to simplify testing ๐Ÿ‘‡